Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
_NIOConcurrency: Rename completeWithAsync(_:) to completeWithTask(_:)…
… and return task (#1911) 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.
- Loading branch information