MtxForLoop.ThreadedForLoop Method

Overload List

#SignatureDescription
1function ThreadedForLoop(IterMin: Integer; IterMax: Integer; MyLoop: TForLoopEvent; Threads: TMtxForLoop; const Context: TObjectArray): Boolean;Call this function to initiate threaded for-loop.
2function ThreadedForLoop(IterMin: Integer; IterMax: Integer; MyLoop: TForLoopRangeEvent; Threads: TMtxForLoop; const Context: TObjectArray): Boolean;Call this function to initiate threaded for-loop.

Overload 1: function ThreadedForLoop(IterMin: Integer; IterMax: Integer; MyLoop: TForLoopEvent; Threads: TMtxForLoop; const Context: TObjectArray): Boolean;

Call this function to initiate threaded for-loop.

#NameTypeDescription
1IterMinInteger
2IterMaxInteger
3MyLoopTForLoopEvent
4ThreadsTMtxForLoop
5ContextTObjectArray

Returns: Boolean

Remarks:

The MyLoop method pointer must be a method. This is the function that will be called (IterMax - IterMin + 1) times. Threads parameter requires a TMtxForLoop object and Context can be used to pass any parameters to the threaded function. Computational load for each Iteration in the range from IterMin to IterMax is allowed to vary (possibly by a lot). Further vectorization within each threaded function call is not possible across the working Iteration range.

Use MtxVec.DoForLoop to take advantage of super-conductive MtxVec object cache. Calling ThreadedForLoop in parallel from multiple threads will not work. The call is to be protected with a critical section or otherwise.

Overload 2: function ThreadedForLoop(IterMin: Integer; IterMax: Integer; MyLoop: TForLoopRangeEvent; Threads: TMtxForLoop; const Context: TObjectArray): Boolean;

Call this function to initiate threaded for-loop.

#NameTypeDescription
1IterMinInteger
2IterMaxInteger
3MyLoopTForLoopRangeEvent
4ThreadsTMtxForLoop
5ContextTObjectArray

Returns: Boolean

Remarks:

The MyLoop method pointer must be a method. This is the function that will be called once by each thread. Threads parameter requires a TMtxForLoop object and the Context parameter can be used to pass any parameters to the threaded function. The threading engine will attempt to equaly partition the job between available threads assuming constant computational load for each Iteration in the range from IterMin to IterMax. However, further vectorization is possible within each threaded function call.

Use MtxVec.DoForLoop to take advantage of super-conductive MtxVec object cache. Calling ThreadedForLoop in parallel from multiple threads will not work. The call is to be protected with a critical section or otherwise.