Skip to content

Commit

Permalink
Add cancellation for Array
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif committed Aug 18, 2022
1 parent 9c15c66 commit 6fe18c3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/Fork/ForkedArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,17 @@ extension ForkedArray {
case let .single(value):
guard try await filter(value) else { return [] }

try Task.checkCancellation()

return [try await using(value)]
case let .fork(fork):
return try await fork.merged(
using: { leftType, rightType in
async let leftOutput = try output(for: leftType, filter: filter, using: using)
async let rightOutput = try output(for: rightType, filter: filter, using: using)

try Task.checkCancellation()

return try await leftOutput + rightOutput
}
)
Expand Down

0 comments on commit 6fe18c3

Please sign in to comment.