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
lowerintThe inclusive lower bound of the range to be processed.
upperintThe exclusive upper bound of the range to be processed.
numTasksintThe number of batches to create.
actionAction<Parallel.Batch>The callback to execute for each batch.
executeboolWhether 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
numElementsintThe total number of elements to divide.
numDivisionsintThe number of divisions (parts).
partintThe zero-based index of the part.
startintThe inclusive start index for the specified part.
endintThe 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).