Futures

  • 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.

    Promise is only able to communicate a single value. If you need to efficiently communicate a sequence of asynchronously produced values, see Channel.Unbuffered.

    See more

    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 AnyFuture to create a custom future by providing a closure for the poll method, rather than implementing FutureProtocol directly on a custom type.

    See more

    Declaration

    Swift

    public struct AnyFuture<Output> : FutureProtocol