procedure CancelProcessing;
Call to cancel the processing.
Result: stored in self (calling object)
Remarks:
This will indicate that looping should stop, but to quit any processing within threaded procedure has to be checked by the procedure explicitely.
procedure MyLoopRange(IdxStart, IdxEnd: integer; const Context: TObjectArray; ThreadIndex: integer);
var j, k: integer;
a: TMtx;
begin
a := TMtx(Context[0]);
for k := IdxStart to IdxEnd do //additional vectorization possible inside these two loops
begin
for j := 0 to a.Cols - 1 do
begin
a[k, j] := a[k, j] + 1;
end;
//Check, if we need to finish prematurely
mtxForLoop[ThreadIndex].CancelProcessing then Exit;
end;
end;Examples
procedure MyLoopRange(IdxStart, IdxEnd: integer; const Context: TObjectArray; ThreadIndex: integer);
var j, k: integer;
a: TMtx;
begin
a := TMtx(Context[0]);
for k := IdxStart to IdxEnd do //additional vectorization possible inside these two loops
begin
for j := 0 to a.Cols - 1 do
begin
a[k, j] := a[k, j] + 1;
end;
//Check, if we need to finish prematurely
mtxForLoop[ThreadIndex].CancelProcessing then Exit;
end;
end;