TMtxForLoop::CancelProcessing Method

void CancelProcessing();

Call to cancel the processing.

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
#include "MtxForLoop.h"
#include "MtxVec.h"

using namespace Dew;
using namespace Dew::Math;

static void MyLoopRange(int IdxStart, int IdxEnd, const DewArray<tObject*>& Context, int ThreadIndex)
{
    int j, k;
    TMtx* a;
    TMtxForLoop* mtxForLoop = (TMtxForLoop*)Context[1];
    a = (TMtx*)Context[0];

    for (k = IdxStart; k <= IdxEnd; k++) //additional vectorization possible inside these two loops
    {
        for (j = 0; j <= a->Cols - 1; j++)
        {
            (*a)(k, j) = (*a)(k, j) + 1;
        }

        //Check, if we need to finish prematurely
        if ((*mtxForLoop)[ThreadIndex]->CancelProcessing) return;
    }
}

void Example()
{
}
Declared in Dew::Math::TMtxForLoop · Dew.Math/MtxForLoop.h · Cross-compiler