ComputeThreadPools

public enum ComputeThreadPools

A namespace for threadpool operations.

  • A global default ComputeThreadPool.

    When you need a ComputeThreadPool use the local ComputeThreadPool, as this allows parts of the app to configure a customized ComputeThreadPool. global is used when the local thread pool hasn’t yet been set. (In particular, the global thread pool is copied into the thread-local storage upon first access.)

    global is made public so that early upon a process start-up (before any references to local are made), code can cofigure a customized global thread pool.

    See also

    local

    Declaration

    Swift

    public static var global: ComputeThreadPool
  • A thread local ComputeThreadPool.

    Use this thread pool whenever you need a thread pool in your applications and have not been provided one by the caller. (Rationale: by using a thread-local instead of a global, regions of code can be easily configured to use a given ComputeThreadPool).

    Declaration

    Swift

    public static var local: ComputeThreadPool { get set }
  • The thread index for the current thread, based on the current thread-local compute pool.

    Declaration

    Swift

    public static var currentThreadIndex: Int? { get }
  • The amount of parallelism provided by the current thread-local compute pool.

    Declaration

    Swift

    public static var maxParallelism: Int { get }
  • Sets pool to local for the duration of body.

    Declaration

    Swift

    public static func withPool<T>(_ pool: ComputeThreadPool, _ body: () throws -> T) rethrows -> T