Futures
-
Declaration
Swift
public protocol FutureConvertible
-
An one-shot slot that can be used to communicate a value between tasks.
Promise
is safe to use between any number of tasks that are racing to provide the value and a single task that is polling for it.
See morePromise
is only able to communicate a single value. If you need to efficiently communicate a sequence of asynchronously produced values, seeChannel.Unbuffered
.Declaration
Swift
public final class Promise<Output> : FutureProtocol
-
Declaration
Swift
public struct Deferred<Output> : FutureProtocol
-
A type-erasing future.
Use
AnyFuture
to wrap a future whose type has details you don’t want to expose. This is typically the case when returning futures from a function or storing futures in properties.You can also use
See moreAnyFuture
to create a custom future by providing a closure for thepoll
method, rather than implementingFutureProtocol
directly on a custom type.Declaration
Swift
public struct AnyFuture<Output> : FutureProtocol
-
Declaration
Swift
public typealias AnyResultFuture<Success, Failure> = AnyFuture<Result<Success, Failure>> where Failure : Error
-
Declaration
Swift
public struct ResultFuture<Success, Failure> : FutureProtocol where Failure : Error