@@ -328,7 +328,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
328328)
329329var channel = consume channelAndSource.channel
330330var source = consume channelAndSource.source
331- source.onTermination = { print (" Terminated" ) }
331+ source.setOnTerminationCallback { print (" Terminated" ) }
332332
333333let task = Task {
334334 await channel.next ()
@@ -344,7 +344,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
344344)
345345var channel = consume channelAndSource.channel
346346var 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)
357357var channel = consume channelAndSource.channel
358358var source = consume channelAndSource.source
359- source.onTermination = { print (" Terminated" ) }
359+ source.setOnTerminationCallback { print (" Terminated" ) }
360360
361361_ = try await source.send (1 )
362362source.finish ()
@@ -374,7 +374,7 @@ let channelAndSource = MultiProducerSingleConsumerChannel.makeChannel(
374374var channel = consume channelAndSource.channel
375375var source1 = consume channelAndSource.source
376376var 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