Class Parallel
- Namespace
- Jitter2.Parallelization
- Assembly
- Jitter2.dll
Provides methods and structures for parallel batch processing within the Jitter physics engine.
public static class Parallel
- Inheritance
-
Parallel
- Inherited Members
Remarks
This class is used internally to distribute work across worker threads via ThreadPool.
Methods
ForBatch(int, int, int, Action<Batch>, bool)
Executes tasks in parallel by dividing the work into batches using the ThreadPool.
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 divide the work into.
actionAction<Parallel.Batch>The callback function to execute for each batch.
executeboolIndicates whether to execute the tasks immediately after adding them to the thread pool.
Remarks
This method splits the range [lower, upper) into numTasks batches and processes each batch in parallel.
The action callback is invoked for each batch, which is represented by a Parallel.Batch struct.
If execute is true, the method will call Execute() to start executing the tasks.
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).