diff --git a/Benchmarks/Package.swift b/Benchmarks/Package.swift index 2745ea6..7e4c352 100644 --- a/Benchmarks/Package.swift +++ b/Benchmarks/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.9 +// swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/Package.swift b/Package.swift index e45bc6a..5963314 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.7 +// swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/Sources/AsyncChannels/Select.swift b/Sources/AsyncChannels/Select.swift index 7d66672..3aad52f 100644 --- a/Sources/AsyncChannels/Select.swift +++ b/Sources/AsyncChannels/Select.swift @@ -17,7 +17,7 @@ protocol SelectProtocol { } @usableFromInline -struct ReceiveHandler: SelectProtocol { +struct ReceiveHandler: SelectProtocol { private var chan: Channel private let outFunc: (T?) async -> () @@ -59,7 +59,7 @@ struct NoneHandler: SelectProtocol { } @usableFromInline -struct SendHandler: SelectProtocol { +struct SendHandler: SelectProtocol { private var chan: Channel private let val: T private let onSend: () async -> () diff --git a/Tests/AsyncChannelsTests/AsyncChannelTests.swift b/Tests/AsyncChannelsTests/AsyncChannelTests.swift index 525455f..815d38e 100644 --- a/Tests/AsyncChannelsTests/AsyncChannelTests.swift +++ b/Tests/AsyncChannelsTests/AsyncChannelTests.swift @@ -15,10 +15,11 @@ final class AsyncTest: XCTestCase { func failAfter(duration: Duration) -> Channel { let stop = Channel() + let sleepSig = sleep(for: .seconds(1)) Task { await select { receive(stop) - receive(sleep(for: duration)) { + receive(sleepSig) { XCTFail("Test timed out") exit(1) } @@ -615,7 +616,7 @@ final class AsyncTest: XCTestCase { a.close() } - class SomeData { + final class SomeData: Sendable { let name: String let age: Int @@ -769,4 +770,40 @@ final class AsyncTest: XCTestCase { XCTAssertEqual(100, sum) } + + func testStopSig() async { + + enum StopSignal { + case error + case done + } + + let data = Channel() + let signal = Channel() + + + Task { + var done = false + while !done { + await select { + receive(data) { print($0!) } + receive(signal) { + switch $0! { + case .error: + print("there was an error") + done = true + case .done: + print("done processing data") + done = true + } + } + } + } + print("done!") + } + + await data <- "foo" + await data <- "bar" + await signal <- .done + } }