Skip to content

Commit

Permalink
Fix Cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty authored and twittemb committed Jan 3, 2023
1 parent 2f596e1 commit a5bf1be
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/Operators/AsyncSwitchToLatestSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,11 @@ where Base.Element: AsyncSequence, Base: Sendable, Base.Element.Element: Sendabl
guard !Task.isCancelled else { return nil }
self.startBase()

return try await withTaskCancellationHandler { [baseTask] in
return try await withTaskCancellationHandler { [baseTask, state] in
baseTask?.cancel()
state.withCriticalRegion {
$0.childTask?.cancel()
}
} operation: {
while true {
let childTask = await withUnsafeContinuation { [state] (continuation: UnsafeContinuation<Task<ChildValue?, Never>?, Never>) in
Expand Down

0 comments on commit a5bf1be

Please sign in to comment.