Skip to content

Commit 4d50bf6

Browse files
committed
Deprecation Housekeeping (apple#206)
`withTaskCancellationHandler<T>(_:, operation:)` -> `withTaskCancellationHandler<T>(operation:onCancel:)`
1 parent 76b27ae commit 4d50bf6

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Sources/AsyncAlgorithms/Zip/Zip2Runtime.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ where Base1: Sendable, Base1.Element: Sendable, Base2: Sendable, Base2.Element:
2424

2525
func next() async rethrows -> (Base1.Element, Base2.Element)? {
2626
try await withTaskCancellationHandler {
27-
let output = self.stateMachine.withCriticalRegion { stateMachine in
28-
stateMachine.rootTaskIsCancelled()
29-
}
30-
// clean the allocated resources and state
31-
self.handle(rootTaskIsCancelledOutput: output)
32-
} operation: {
3327
let results = await withUnsafeContinuation { continuation in
3428
self.stateMachine.withCriticalRegion { stateMachine in
3529
let output = stateMachine.newDemandFromConsumer(suspendedDemand: continuation)
@@ -59,6 +53,12 @@ where Base1: Sendable, Base1.Element: Sendable, Base2: Sendable, Base2.Element:
5953
}
6054

6155
return try (results.0._rethrowGet(), results.1._rethrowGet())
56+
} onCancel: {
57+
let output = self.stateMachine.withCriticalRegion { stateMachine in
58+
stateMachine.rootTaskIsCancelled()
59+
}
60+
// clean the allocated resources and state
61+
self.handle(rootTaskIsCancelledOutput: output)
6262
}
6363
}
6464

Sources/AsyncAlgorithms/Zip/Zip3Runtime.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ where Base1: Sendable, Base1.Element: Sendable, Base2: Sendable, Base2.Element:
2626

2727
func next() async rethrows -> (Base1.Element, Base2.Element, Base3.Element)? {
2828
try await withTaskCancellationHandler {
29-
let output = self.stateMachine.withCriticalRegion { stateMachine in
30-
stateMachine.rootTaskIsCancelled()
31-
}
32-
// clean the allocated resources and state
33-
self.handle(rootTaskIsCancelledOutput: output)
34-
} operation: {
3529
let results = await withUnsafeContinuation { continuation in
3630
self.stateMachine.withCriticalRegion { stateMachine in
3731
let output = stateMachine.newDemandFromConsumer(suspendedDemand: continuation)
@@ -61,6 +55,12 @@ where Base1: Sendable, Base1.Element: Sendable, Base2: Sendable, Base2.Element:
6155
}
6256

6357
return try (results.0._rethrowGet(), results.1._rethrowGet(), results.2._rethrowGet())
58+
} onCancel: {
59+
let output = self.stateMachine.withCriticalRegion { stateMachine in
60+
stateMachine.rootTaskIsCancelled()
61+
}
62+
// clean the allocated resources and state
63+
self.handle(rootTaskIsCancelledOutput: output)
6464
}
6565
}
6666

0 commit comments

Comments
 (0)