Cancel all operations
- Dominant language
- Swift
- Stars
- 43
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Can we add a `cancelAllOperations()` method?
Currently, this conflicts with the fact that the `perform` methods prefer running in the current task:
```swift
// AsyncQueues 0.3.0
let queue = AsyncQueue()
await queue.perform {
// In the same task as the caller
}
```
For `cancelAllOperations()` to work, we'd need to run those operations in a distinct task:
```swift
// With hypothetic support for cancelling all operations
let queue = AsyncQueue()
await queue.perform {
// Must be in a distinct task than the caller
// so that we can cancel this operation.
}
```
This would be a breaking change:
```swift
let queue = AsyncQueue()
await queue.perform {
// Would not cancel the same task
withUnsafeCurrentTask { currentTask in
currentTask?.cancel()
}
}
```
cc @mattmassicotte - in case you'd have hindsights about the differences between running in the current task vs. a new top-level Task created from the current task, and why one could prefer one or the other.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.