Table of Contents

Class Parallel

Namespace
Jitter2.Parallelization
Assembly
Jitter2.dll

Divides index ranges into batches for processing with ThreadPool.

public static class Parallel
Inheritance
Parallel
Inherited Members

Methods

ForBatch(int, int, int, Action<Batch>, bool)

Divides an index range into batches and queues a callback for each batch.

public static void ForBatch(int lower, int upper, int numTasks, Action<Parallel.Batch> action, bool execute = true)

Parameters

lower int

The inclusive lower bound of the range to be processed.

upper int

The exclusive upper bound of the range to be processed.

numTasks int

The number of batches to create.

action Action<Parallel.Batch>

The callback to execute for each batch.

execute bool

Whether to execute the queued batches immediately.

Remarks

Callbacks may run concurrently. When execute is true, this method waits for all queued tasks to finish. Otherwise, call Execute() on the shared pool to run them later. Queueing batches is not thread-safe.

GetBounds(int, int, int, out int, out int)

Computes the start and end indices for a specific part of an evenly divided range.

public static void GetBounds(int numElements, int numDivisions, int part, out int start, out int end)

Parameters

numElements int

The total number of elements to divide.

numDivisions int

The number of divisions (parts).

part int

The zero-based index of the part.

start int

The inclusive start index for the specified part.

end int

The exclusive end index for the specified part.

Remarks

Distributes remainder elements across the first parts. For example, with 14 elements and 4 divisions: part 0 gets [0,4), part 1 gets [4,8), part 2 gets [8,11), part 3 gets [11,14).