Skip to content

Package

AsyncKit

Provides a set of utilities for working with EventLoopFutures and other pre-Concurrency support APIs.

Overview

AsyncKit is a legacy package; its use is not recommended in new projects.

AsyncKit provides a number of extensions to both Swift’s Concurrency primitives and NIO’s futures to make working with them easier. The long-term goal is to migrate away from this package as Swift Concurrency adds support for working in an asynchronous environment easy.

See references below for usage details.

Topics

Legacy connection pools

Optionals

EventLoop and EventLoopGroup

  • flatten(_:)
    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.
  • flatten(_:)
    Returns a new EventLoopFuture that succeeds only when all the provided futures succeed, ignoring the resolved values.
  • future()
    Creates a new, succeeded EventLoopFuture from the worker’s event loop with a Void value.
  • future(error:)
    Creates a new, failed EventLoopFuture from the worker’s event loop.
  • future(_:)
    Creates a new, succeeded EventLoopFuture from the worker’s event loop.
  • future(result:)
    Creates a new Future from the worker’s event loop, succeeded or failed based on the input Result.
  • tryFuture(_:)
    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.

EventLoopFuture

EventLoopFuture operators

  • +(_:_:)
    Adds two futures and produces their sum
  • +(_:_:)
    Adds two futures and produces their sum
  • +=(_:_:)
    Adds two futures and stores the result in the left-hand-side variable
  • +=(_:_:)
    Adds two futures and stores the result in the left-hand-side variable
  • *(_:_:)
    Multiplies two futures and produces their product
  • *=(_:_:)
    Multiplies two futures and stores the result in the left-hand-side variable
  • %(_:_:)
    Returns the remainder of dividing the first future by the second
  • %=(_:_:)
    Divides the first future by the second and stores the remainder in the left-hand-side variable
  • <(_:_:)
    Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument
  • <=(_:_:)
    Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument
  • >(_:_:)
    Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument
  • >=(_:_:)
    Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument
  • <<(_:_:)
    Returns the result of shifting a future’s binary representation the specified number of digits to the left
  • <<=(_:_:)
    Stores the result of shifting a future’s binary representation the specified number of digits to the left in the left-hand-side variable
  • >>(_:_:)
    Returns the result of shifting a future’s binary representation the specified number of digits to the right
  • >>=(_:_:)
    Stores the result of shifting a future’s binary representation the specified number of digits to the right in the left-hand-side variable
  • &(_:_:)
    Returns the result of performing a bitwise AND operation on the two given futures
  • &=(_:_:)
    Stores the result of performing a bitwise AND operation on the two given futures in the left-hand-side variable
  • |(_:_:)
    Returns the result of performing a bitwise OR operation on the two given futures
  • |=(_:_:)
    Stores the result of performing a bitwise OR operation on the two given futures in the left-hand-side variable
  • ^(_:_:)
    Returns the result of performing a bitwise XOR operation on the two given futures
  • ^=(_:_:)
    Stores the result of performing a bitwise XOR operation on the two given futures in the left-hand-side variable
  • ~(_:)
    Returns the result of performing a bitwise NOT operation on the given future

Extended Modules