@@ -328,7 +328,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
328
328
)
329
329
var channel = consume channelAndSource.channel
330
330
var source = consume channelAndSource.source
331
- source.onTermination = { print (" Terminated" ) }
331
+ source.setOnTerminationCallback { print (" Terminated" ) }
332
332
333
333
let task = Task {
334
334
await channel.next ()
@@ -344,7 +344,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
344
344
)
345
345
var channel = consume channelAndSource.channel
346
346
var source = consume channelAndSource.source
347
- source.onTermination = { print (" Terminated" ) }
347
+ source.setOnTerminationCallback { print (" Terminated" ) }
348
348
_ = consume channel // Prints Terminated
349
349
```
350
350
@@ -356,7 +356,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
356
356
)
357
357
var channel = consume channelAndSource.channel
358
358
var source = consume channelAndSource.source
359
- source.onTermination = { print (" Terminated" ) }
359
+ source.setOnTerminationCallback { print (" Terminated" ) }
360
360
361
361
_ = try await source.send (1 )
362
362
source.finish ()
@@ -374,7 +374,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
374
374
var channel = consume channelAndSource.channel
375
375
var source1 = consume channelAndSource.source
376
376
var source2 = source1.copy ()
377
- source1.onTermination = { print (" Terminated" ) }
377
+ source1.setOnTerminationCallback { print (" Terminated" ) }
378
378
379
379
_ = try await source1.send (1 )
380
380
_ = consume source1
@@ -601,9 +601,7 @@ extension MultiProducerSingleConsumerChannel {
601
601
/// A callback to invoke when the channel finished.
602
602
///
603
603
/// 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 )
607
605
608
606
/// Creates a new source which can be used to send elements to the channel concurrently.
609
607
///
0 commit comments