start a new task
Start(fcn, arg1, ..., argN)
(appliable) the function to execute in the Task
(anything) the arguments to fcn or the specification of child tasks
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.
cont := proc( a, b )
return a + b;
cont ≔ proca,breturna+bend proc
task := proc( i, j )
if ( j-i < 1000 ) then
return add( k, k=i..j );
k := floor( (j-i)/2 )+i;
Continue( cont, Task=[ task, i, k ], Task=[ task, k+1, j ] );
task ≔ proci,jlocalk;ifj − i<1000thenreturnadd⁡k,k=i..jelsek ≔ floor⁡1/2*j − 1/2*i+i;Threads:-Task:-Continue⁡cont,Task=task,i,k,Task=task,k+1,jend ifend proc
The Threads[Task][Start] command was updated in Maple 15.
Task Programming Model
Download Help Document
What kind of issue would you like to report? (Optional)