Snippet: Spawning Child Threads

Prerequisites:

Process Parameters:

Parameter

Type

Prompt

Value

Parameter

Type

Prompt

Value

pLogOutput

String

Record in process log

1

pMaxThreads

String

Optional: Maximum number of threads for parallel processing: default =1

1

pDimPar

String

Optional: Parallelization dimension: default =blank (FIN Company)

 

pThreadID

String

Private: Thread ID (don't override, leave 0 as default)

0

Prolog (before Initialize Logging region)

pLogOutput = TRIM( pLogOutput ); nLogOutput = StringToNumber( If( pLogOutput @= '', '0', pLogOutput ));

Prolog (after trimming parameter values):

nMaxThreads = StringToNumber( If( pMaxThreads @= '', '0', pMaxThreads )); nThreadID = StringToNumber( If( pThreadID @= '', '0', pThreadID ));

Prolog (declarations):

cCubParam = '}APQ Settings'; cDimPar = 'FIN Company'; cCubThreadCtrl = '}APQ C3 Thread Control'; cDimensionDelim = CellGetS( cCubParam, 'pDimDelim', 'String' ); cElementStartDelim = CellGetS( cCubParam, 'pEleStartDelim', 'String' ); cElementDelim = CellGetS( cCubParam, 'pEleDelim', 'String' ); cLogRecordThresholdRec = CellGetN( cCubParam, 'Progress logging threshold - number of records', 'Numeric' ); cLogRecordThresholdSec = CellGetN( cCubParam, 'Progress logging threshold - time', 'Numeric' ); cThreadPollingInterval = CellGetN( cCubParam, 'Thread polling interval (seconds)', 'Numeric' ); cMaxRunTime = CellGetN( cCubParam, 'Maximum run time allowed for parallel processing (seconds)', 'Numeric' ); cMaxInitTime = CellGetN( cCubParam, 'Maximum process initialization time allowed for parallel processing (seconds)', 'Numeric' ); cThreadMonitoringEnabled = 1; If( cMaxRunTime <= 0 % cMaxRunTime > 0 & nMaxThreads = 1 ); cMaxRunTime = 0; cThreadMonitoringEnabled = 0; EndIf; sMaxRunTime = NumberToString( cMaxRunTime );

Prolog (parameter testing region):

Prolog (after parameter testing region):

Prolog:

Â