mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Motivation: A number of NIO APIs are asynchronous and return futures but have synchronous implementations. If a caller wants to operate on this they need to register a callback with the future and then operate on the result. However, now that we have an isolated view on the event loop future we can provide a fast path: just check whether the result is already present. This is particularly helpful for channel initializers which are typically synchronous. Using the fast path means calls can avoid an escaping closure from registering a callback on the future. Modifications: Add three new APIs to the isolated event loop future: - `result` which returns the underlying `Result<Value, Error>` or `nil` if it hasn't been completed yet - `value` which call `try result.get()`, and - `isComplete` Result: APIs for accessing the result of an ELF from its isolated view if it's already completed