From 84cea56d2473e9519bdb794f1dc658592b4e8d95 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Tue, 9 Jun 2026 12:24:56 +1000 Subject: [PATCH] trim imports for non-Darwin builds don't import Foundation if FoundationEssentials available; conditionally and explicitly import Dispatch --- Sources/AsyncQueue/CancellableQueue.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/AsyncQueue/CancellableQueue.swift b/Sources/AsyncQueue/CancellableQueue.swift index dd543d8..05e9bca 100644 --- a/Sources/AsyncQueue/CancellableQueue.swift +++ b/Sources/AsyncQueue/CancellableQueue.swift @@ -20,7 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import Foundation +#if canImport(FoundationEssentials) + import FoundationEssentials +#else + import Foundation +#endif +#if canImport(Dispatch) + import Dispatch +#endif /// A queue wrapper that enables cancelling all currently executing and pending tasks. /// @@ -398,7 +405,7 @@ private final class Lock: @unchecked Sendable { // MARK: Fileprivate - fileprivate func withLock(_ body: @Sendable (inout State) throws -> R) rethrows -> R where R: Sendable { + fileprivate func withLock(_ body: @Sendable (inout State) throws -> R) rethrows -> R { try lockQueue.sync { try body(&unsafeValue) }