Table of Contents

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

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 divide the work into.

action Action<Parallel.Batch>

The callback function to execute for each batch.

execute bool

Indicates 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

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).