mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-24 04:17:52 +00:00
`withTaskCancellationHandler<T>(_:, operation:)` -> `withTaskCancellationHandler<T>(operation:onCancel:)`
This commit is contained in:
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user