Deprecation Housekeeping (#206) (#207)

`withTaskCancellationHandler<T>(_:, operation:)` -> `withTaskCancellationHandler<T>(operation:onCancel:)`
This commit is contained in:
Doug Russell authored and GitHub committed 2022-10-11 19:54:17 +01:00
1 parent 76b27aebef
commit 081ca79161
2 files changed
+12 -12

No files matched your search

@@ -24,12 +24,6 @@ where Base1: Sendable, Base1.Element: Sendable, Base2: Sendable, Base2.Element:
func next() async rethrows -> (Base1.Element, Base2.Element)? {
try await withTaskCancellationHandler {
let output = self.stateMachine.withCriticalRegion { stateMachine in
stateMachine.rootTaskIsCancelled()
}
// clean the allocated resources and state
self.handle(rootTaskIsCancelledOutput: output)
} operation: {
let results = await withUnsafeContinuation { continuation in
self.stateMachine.withCriticalRegion { stateMachine in
let output = stateMachine.newDemandFromConsumer(suspendedDemand: continuation)
@@ -59,6 +53,12 @@ where Base1: Sendable, Base1.Element: Sendable, Base2: Sendable, Base2.Element:
}
return try (results.0._rethrowGet(), results.1._rethrowGet())
} onCancel: {
let output = self.stateMachine.withCriticalRegion { stateMachine in
stateMachine.rootTaskIsCancelled()
}
// clean the allocated resources and state
self.handle(rootTaskIsCancelledOutput: output)
}
}
@@ -26,12 +26,6 @@ where Base1: Sendable, Base1.Element: Sendable, Base2: Sendable, Base2.Element:
func next() async rethrows -> (Base1.Element, Base2.Element, Base3.Element)? {
try await withTaskCancellationHandler {
let output = self.stateMachine.withCriticalRegion { stateMachine in
stateMachine.rootTaskIsCancelled()
}
// clean the allocated resources and state
self.handle(rootTaskIsCancelledOutput: output)
} operation: {
let results = await withUnsafeContinuation { continuation in
self.stateMachine.withCriticalRegion { stateMachine in
let output = stateMachine.newDemandFromConsumer(suspendedDemand: continuation)
@@ -61,6 +55,12 @@ where Base1: Sendable, Base1.Element: Sendable, Base2: Sendable, Base2.Element:
}
return try (results.0._rethrowGet(), results.1._rethrowGet(), results.2._rethrowGet())
} onCancel: {
let output = self.stateMachine.withCriticalRegion { stateMachine in
stateMachine.rootTaskIsCancelled()
}
// clean the allocated resources and state
self.handle(rootTaskIsCancelledOutput: output)
}
}