InlineComputeThreadPool
public struct InlineComputeThreadPool : ComputeThreadPool
A ComputeThreadPool
that executes everything immediately on the current thread.
This threadpool implementation is useful for testing correctness, as well as avoiding context switches when a computation is designed to be parallelized at a coarser level.
-
Initializes
self
.Declaration
Swift
public init()
-
The maximum number of concurrent threads of execution supported by this thread pool.
Declaration
Swift
public var maxParallelism: Int { get }
-
The index of the current thread.
Declaration
Swift
public var currentThreadIndex: Int? { get }
-
Dispatch
fn
to be run at some point in the future (immediately).Note: this implementation just executes
fn
immediately.Declaration
Swift
public func dispatch(_ fn: () -> Void)
-
Executes
a
andb
optionally in parallel, and returns when both are complete.Note: this implementation simply executes them serially.
Declaration
Swift
public func join(_ a: () -> Void, _ b: () -> Void)
-
Executes
a
andb
optionally in parallel, and returns when both are complete.Note: this implementation simply executes them serially.
Declaration
Swift
public func join(_ a: () throws -> Void, _ b: () throws -> Void) throws
-
Declaration
Swift
public func parallelFor(n: Int, _ fn: VectorizedParallelForBody)
-
Declaration
Swift
public func parallelFor(n: Int, _ fn: ThrowingVectorizedParallelForBody) throws