ComputeThreadPools
public enum ComputeThreadPools
A namespace for threadpool operations.
-
A global default
ComputeThreadPool
.When you need a
ComputeThreadPool
use thelocal
ComputeThreadPool
, as this allows parts of the app to configure a customizedComputeThreadPool
.global
is used when thelocal
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 tolocal
are made), code can cofigure a customizedglobal
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
tolocal
for the duration ofbody
.Declaration
Swift
public static func withPool<T>(_ pool: ComputeThreadPool, _ body: () throws -> T) rethrows -> T