 Start - Maple Help

 Start Calling Sequence Start(fcn, arg1,  ..., argN) Parameters

 fcn - (appliable) the function to execute in the Task args1..argsN - (anything) the arguments to fcn or the specification of child tasks Description

 • The Start function creates a new invocation of the Task Model.  Start creates a root task and then starts executing tasks until the current invocation exits, either because the all the tasks complete or because the Return function is called.  The return value of Start is the value returned by the final task or the value passed into Return.
 • The Start function is part of the Task Programming Model.
 • If no child tasks are specified, then Start creates one task which evaluates fnc( args11...argsN ).
 • If child tasks are specified, then Start creates one task for each child, and a continuation task with fnc as the continuation function. The value of fnc is either a procedure or the name of a predefined continuation function.
 • The two predefined continuation functions are passed and null
 passed returns the arguments that were passed into it.
 null returns NULL.
 • An argument to Start of the form
 Task = [ cfcn, carg1 ... cargn ]
 creates a child task that executes the following command.
 cfcn( carg1 ... cargn )
 • An argument to Start of the form:
 Tasks = [ cfcn, [c1args] ... [cnargs] ]
 behaves as if multiple Task arguments of the form
 Task = [ cfcn, c1args ], Task = [ cfcn, c2args ], ... Task = [ cfcn, cnargs ]
 had been given.  Thus, it creates tasks to execute the following commands.
 cfcn( c1args ), cfcn( c2args ) ... cfcn( cnargs )
 • The return value of a child task is passed to the continuation function in the child's position in its argument sequence.
 • Arguments not of the form described above are passed to the continuation function fcn as arguments in the corresponding positions.
 • If child tasks are created as part of the call to Start, the continuation task will not start executing until all of its child tasks have completed. Examples

 > with(Threads[Task]); cont := proc( a, b )    return a + b; end proc;
 $\left[{\mathrm{Continue}}{,}{\mathrm{Return}}{,}{\mathrm{Start}}\right]$
 ${\mathrm{cont}}{≔}{\mathbf{proc}}\left({a}{,}{b}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{a}{+}{b}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > task := proc( i, j )    local k;    if ( j-i < 1000 ) then        return add( k, k=i..j );    else        k := floor( (j-i)/2 )+i;        Continue( cont, Task=[ task, i, k ], Task=[ task, k+1, j ] );    end if; end proc;
 ${\mathrm{task}}{≔}{\mathbf{proc}}\left({i}{,}{j}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{k}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{j}{-}{i}{<}{1000}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{add}}{}\left({k}{,}{k}{=}{i}{..}{j}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{else}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{k}{≔}{\mathrm{floor}}{}\left({1}{/}{2}{*}{j}{-}{1}{/}{2}{*}{i}\right){+}{i}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Threads}}{:-}{\mathrm{Task}}{:-}{\mathrm{Continue}}{}\left({\mathrm{cont}}{,}{\mathrm{Task}}{=}\left[{\mathrm{task}}{,}{i}{,}{k}\right]{,}{\mathrm{Task}}{=}\left[{\mathrm{task}}{,}{k}{+}{1}{,}{j}\right]\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2)
 > $\mathrm{Start}\left(\mathrm{task},1,{10}^{7}\right)$
 ${50000005000000}$ (3)
 > $\mathrm{Start}\left(\mathrm{cont},\mathrm{Task}=\left[\mathrm{task},1,5{10}^{6}\right],\mathrm{Task}=\left[\mathrm{task},5{10}^{6}+1,{10}^{7}\right]\right)$
 ${50000005000000}$ (4)
 > $\mathrm{Start}\left(\mathrm{cont},\mathrm{Tasks}=\left[\mathrm{task},\left[1,5{10}^{6}\right],\left[5{10}^{6}+1,{10}^{7}\right]\right]\right)$
 ${50000005000000}$ (5)
 > $\mathrm{add}\left(i,i=1..{10}^{7}\right)$
 ${50000005000000}$ (6) Compatibility