Table of Contents

Class ParallelExtensions

Namespace
Jitter2.Parallelization
Assembly
Jitter2.dll

Divides collections into index ranges for parallel processing.

public static class ParallelExtensions
Inheritance
ParallelExtensions
Inherited Members

Remarks

Callbacks may run concurrently. With execute: true, each method waits for completion; otherwise, call Execute() on the shared pool to run the queued batches. Do not queue batches concurrently or change a collection while its batches are being processed.

Methods

ParallelForBatch(Array, int, Action<Batch>, bool)

Processes array elements in parallel batches.

public static int ParallelForBatch(this Array array, int taskThreshold, Action<Parallel.Batch> action, bool execute = true)

Parameters

array Array

The array to process.

taskThreshold int

Positive target batch size used to choose the number of batches; actual batches can be smaller or larger.

action Action<Parallel.Batch>

The callback to invoke for each batch.

execute bool

If true, calls Execute() to start execution.

Returns

int

The number of batches generated.

ParallelForBatch<T>(ReadOnlyPartitionedSet<T>, int, Action<Batch>, bool)

Processes active elements of a ReadOnlyPartitionedSet<T> in parallel batches.

public static int ParallelForBatch<T>(this ReadOnlyPartitionedSet<T> list, int taskThreshold, Action<Parallel.Batch> action, bool execute = true) where T : class, IPartitionedSetIndex

Parameters

list ReadOnlyPartitionedSet<T>

The set to process.

taskThreshold int

Positive target batch size used to choose the number of batches; actual batches can be smaller or larger.

action Action<Parallel.Batch>

The callback to invoke for each batch.

execute bool

If true, calls Execute() to start execution.

Returns

int

The number of batches generated.

Type Parameters

T

The element type.

ParallelForBatch<T>(PartitionedBuffer<T>, int, Action<Batch>, bool)

Processes active elements of a PartitionedBuffer<T> in parallel batches.

public static int ParallelForBatch<T>(this PartitionedBuffer<T> list, int taskThreshold, Action<Parallel.Batch> action, bool execute = true) where T : unmanaged

Parameters

list PartitionedBuffer<T>

The buffer to process.

taskThreshold int

Positive target batch size used to choose the number of batches; actual batches can be smaller or larger.

action Action<Parallel.Batch>

The callback to invoke for each batch.

execute bool

If true, calls Execute() to start execution.

Returns

int

The number of batches generated.

Type Parameters

T

The unmanaged element type.