Home Online Manual
Top
Back: stopTask
Forward: waitAllTasks
FastBack:
FastForward:
Up: tasks_lib
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

D.2.13.8 waitTasks

Procedure from library tasks.lib (see tasks_lib).

Usage:
waitTasks(T, N[, timeout]), T list of tasks, N int, timeout int

Return:
an ordered list of the indices of those tasks which have been successfully completed. The state of these tasks is set to 'completed'.
The procedure waits for N tasks to complete.
An optional timeout in ms can be provided. Default is 0 which disables the timeout.

Note:
A task whose state is neither 'started' nor 'completed' cannot be waited for.
The result of any completed task can be accessed via getResult.
The returned list may contain more than N entries if the computation of some tasks has already finished and/or if several tasks finish "at the same time". It may contain less than N entries in the case of timeout or errors occurring.
Polling is guaranteed, i.e. the index of any task t for which 'pollTask(t);' would return 1 will appear in the returned list.

Example:
 
LIB "tasks.lib";
ring R = 0, (x,y), dp;
ideal I = x9y2+x10, x2y7-y8;
task t1 = "std", list(I);
task t2 = "slimgb", list(I);
startTasks(t1, t2);
waitTasks(list(t1, t2), 2);   // wait for both tasks
==> [1]:
==>    1
==> [2]:
==>    2
getResult(t1);
==> _[1]=x2y7-y8
==> _[2]=x9y2+x10
==> _[3]=x12y+xy11
==> _[4]=x13-xy12
==> _[5]=y14+xy12
==> _[6]=xy13+y12
getResult(t2);
==> _[1]=x2y7-y8
==> _[2]=x9y2+x10
==> _[3]=x12y+xy11
==> _[4]=x13-xy12
==> _[5]=xy13+y12
==> _[6]=y14+xy12
killTask(t1);
killTask(t2);
See also: getResult; getState; pollTask; printTask; startTasks.