Skip to content

Commit baf72ef

Browse files
committed
Fix Swift 6.0 build
1 parent 712bc12 commit baf72ef

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

Sources/AsyncAlgorithms/MultiProducerSingleConsumerChannel/MultiProducerSingleConsumerChannel.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,15 @@ extension MultiProducerSingleConsumerChannel.ChannelAsyncSequence where Element:
546546
init(storage: MultiProducerSingleConsumerChannel._Storage) {
547547
self._backing = .init(storage: storage)
548548
}
549+
550+
@inlinable
551+
mutating func next() async throws -> Element? {
552+
do {
553+
return try await self._backing.storage.next(isolation: nil)
554+
} catch {
555+
throw error as! Failure
556+
}
557+
}
549558

550559
@inlinable
551560
mutating func next(

Sources/Example/Example.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct Example {
2222
count: Int,
2323
backpressureStrategy: MultiProducerSingleConsumerChannel<Int, Never>.Source.BackpressureStrategy
2424
) async {
25-
await withTaskGroup { group in
25+
await withTaskGroup(of: Void.self) { group in
2626
let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
2727
of: Int.self,
2828
backpressureStrategy: backpressureStrategy
@@ -47,7 +47,7 @@ struct Example {
4747
}
4848

4949
static func testAsyncStream(count: Int) async {
50-
await withTaskGroup { group in
50+
await withTaskGroup(of: Void.self) { group in
5151
let (stream, continuation) = AsyncStream.makeStream(of: Int.self, bufferingPolicy: .unbounded)
5252

5353
group.addTask {

Tests/AsyncAlgorithmsTests/MultiProducerSingleConsumerChannel/MultiProducerSingleConsumerChannelTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class MultiProducerSingleConsumerChannelTests: XCTestCase {
1818

1919
func testSourceDeinitialized_whenChanneling_andNoSuspendedConsumer() async throws {
2020
let manualExecutor = ManualTaskExecutor()
21-
try await withThrowingTaskGroup { group in
21+
try await withThrowingTaskGroup(of: Void.self) { group in
2222
let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
2323
of: Int.self,
2424
backpressureStrategy: .watermark(low: 5, high: 10)
@@ -32,7 +32,7 @@ final class MultiProducerSingleConsumerChannelTests: XCTestCase {
3232
}
3333

3434
group.addTask(executorPreference: manualExecutor) {
35-
await channel.next()
35+
_ = await channel.next()
3636
}
3737

3838
withExtendedLifetime(source) {}
@@ -46,7 +46,7 @@ final class MultiProducerSingleConsumerChannelTests: XCTestCase {
4646

4747
func testSourceDeinitialized_whenChanneling_andSuspendedConsumer() async throws {
4848
let manualExecutor = ManualTaskExecutor()
49-
try await withThrowingTaskGroup { group in
49+
try await withThrowingTaskGroup(of: Void.self) { group in
5050
let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
5151
of: Int.self,
5252
backpressureStrategy: .watermark(low: 5, high: 10)
@@ -59,7 +59,7 @@ final class MultiProducerSingleConsumerChannelTests: XCTestCase {
5959
}
6060

6161
group.addTask(executorPreference: manualExecutor) {
62-
await channel.next()
62+
_ = await channel.next()
6363
}
6464
manualExecutor.run()
6565
XCTAssertFalse(didTerminate)
@@ -204,7 +204,7 @@ final class MultiProducerSingleConsumerChannelTests: XCTestCase {
204204

205205
func testSequenceDeinitialized_whenChanneling_andNoSuspendedConsumer() async throws {
206206
let manualExecutor = ManualTaskExecutor()
207-
try await withThrowingTaskGroup { group in
207+
try await withThrowingTaskGroup(of: Void.self) { group in
208208
let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
209209
of: Int.self,
210210
backpressureStrategy: .watermark(low: 5, high: 10)
@@ -216,7 +216,7 @@ final class MultiProducerSingleConsumerChannelTests: XCTestCase {
216216
source.setOnTerminationCallback { didTerminate = true }
217217

218218
group.addTask(executorPreference: manualExecutor) {
219-
await asyncSequence.first { _ in true }
219+
_ = await asyncSequence.first { _ in true }
220220
}
221221

222222
withExtendedLifetime(source) {}
@@ -598,7 +598,7 @@ final class MultiProducerSingleConsumerChannelTests: XCTestCase {
598598
}
599599

600600
func testWrite_whenConcurrentProduction() async throws {
601-
await withThrowingTaskGroup { group in
601+
await withThrowingTaskGroup(of: Void.self) { group in
602602
let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
603603
of: Int.self,
604604
backpressureStrategy: .watermark(low: 2, high: 5)

0 commit comments

Comments
 (0)