mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Return `Task` from `EventLoopPromise.completeWithAsync(_:)` wrapper. Motivation: Bridging an `async` function into NIO is done by calling `completeWithAsync(_ body:)` on an `EventLoopPromise`. This spins up a `Task` and `await`s the result of the `async` closure that was passed in and uses the result to fulfil the promise with the value of the function, if it was successful, or with the error, if the function threw. In some cases we may want to cancel this operation from the outside. Modifications: This patch adds a discardable return value to `EventLoopPromise.completeWithAsync(_:)` which is the `Task` it creates. Result: Users of `EventLoopPromise.completeWithAsync(_:)` are now able to explicitly cancel the `Task` that is being used to fulfil the promise.