Skip to content

Commit 02b6c86

Browse files
committed
FIxup setOnTerminationCallback
1 parent c3911f1 commit 02b6c86

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Evolution/0016-mutli-producer-single-consumer-channel.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
328328
)
329329
var channel = consume channelAndSource.channel
330330
var source = consume channelAndSource.source
331-
source.onTermination = { print("Terminated") }
331+
source.setOnTerminationCallback { print("Terminated") }
332332

333333
let task = Task {
334334
await channel.next()
@@ -344,7 +344,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
344344
)
345345
var channel = consume channelAndSource.channel
346346
var source = consume channelAndSource.source
347-
source.onTermination = { print("Terminated") }
347+
source.setOnTerminationCallback { print("Terminated") }
348348
_ = consume channel // Prints Terminated
349349
```
350350

@@ -356,7 +356,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
356356
)
357357
var channel = consume channelAndSource.channel
358358
var source = consume channelAndSource.source
359-
source.onTermination = { print("Terminated") }
359+
source.setOnTerminationCallback { print("Terminated") }
360360

361361
_ = try await source.send(1)
362362
source.finish()
@@ -374,7 +374,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
374374
var channel = consume channelAndSource.channel
375375
var source1 = consume channelAndSource.source
376376
var source2 = source1.copy()
377-
source1.onTermination = { print("Terminated") }
377+
source1.setOnTerminationCallback { print("Terminated") }
378378

379379
_ = try await source1.send(1)
380380
_ = consume source1
@@ -601,9 +601,7 @@ extension MultiProducerSingleConsumerChannel {
601601
/// A callback to invoke when the channel finished.
602602
///
603603
/// This is called after the last element has been consumed by the channel.
604-
public func setOnTerminationCallback(_ callback: @escaping @Sendable () -> Void) {
605-
self._storage.onTermination = callback
606-
}
604+
public func setOnTerminationCallback(_ callback: @escaping @Sendable () -> Void)
607605

608606
/// Creates a new source which can be used to send elements to the channel concurrently.
609607
///

0 commit comments

Comments
 (0)