future(error:)
Creates a new, failed EventLoopFuture
from the worker’s event loop.
func future<T>(error: Error) -> EventLoopFuture<T>
Parameters
- error
The error that the future will wrap.
Returns
The failed future.
let b: EvenLoopFuture
Creates a new, failed EventLoopFuture
from the worker’s event loop.
func future<T>(error: Error) -> EventLoopFuture<T>
s7NIOCore14EventLoopGroupP8AsyncKitE6future5errorAA0bC6FutureCyqd__Gs5Error_p_tlF
What are these?2JOCX
The error that the future will wrap.
The failed future.
let b: EvenLoopFuture
import NIOCore
The core abstractions that make up SwiftNIO.
import AsyncKit
Provides a set of utilities for working with EventLoopFutures and other pre-Concurrency support APIs.
protocol EventLoopGroup : AnyObject, _NIOPreconcurrencySendable
Provides an endless stream of EventLoop
s to use.
protocol Error : Sendable
A type representing an error value that can be thrown.
final class EventLoopFuture<Value>
Holder for a result that will be provided later.
func flatten<T>(_ futures: [EventLoopFuture<T>]) -> EventLoopFuture<[T]>
Returns a new EventLoopFuture
that succeeds only when all the provided futures succeed. The new EventLoopFuture
contains an array of results, maintaining same ordering as the futures.
func flatten(_ futures: [EventLoopFuture<Void>]) -> EventLoopFuture<Void>
Returns a new EventLoopFuture
that succeeds only when all the provided futures succeed, ignoring the resolved values.
func future() -> EventLoopFuture<Void>
Creates a new, succeeded EventLoopFuture
from the worker’s event loop with a Void
value.
func future<T>(_ value: T) -> EventLoopFuture<T>
Creates a new, succeeded EventLoopFuture
from the worker’s event loop.
func future<T>(result: Result<T, Error>) -> EventLoopFuture<T>
Creates a new Future
from the worker’s event loop, succeeded or failed based on the input Result
.
func tryFuture<T>(_ work: @escaping () throws -> T) -> EventLoopFuture<T>
An alternate name for this would be future(catching:)
, but with that name, trailing closure syntax just looks like el.future { ... }
, which does not indicate to readers of the code that it is the error-capturing version. Since such an indication is highly desirable, a slightly less idiomatic name is used instead.
func makeFutureWithTask<Value>(_ body: @escaping () async throws -> Value) -> EventLoopFuture<Value>
func performWithTask<Value>(_ body: @escaping () async throws -> Value) -> EventLoopFuture<Value>
Run the async
function body
on an event loop in this group and return its result as an EventLoopFuture
.