Tasks
Timing out on a Blocking Operation
task body My_Task is
Elem : A_Queue_Element;
begin
loop -- processing loop
select
A_Queue.Blocking_Queue (Elem);
or
-- Stop processing after a 1 second timeout. Removing this delay causes
-- immediate exit if a block occurs.
delay 1.0;
exit;
end select;
-- ... process Elem ...
end loop
end My_Task;
Waiting for all tasks to complete
A list of statements doesn't exit until all tasks are complete, so by using
declare ... begin ... end
you can wait until all your tasks are done.
declare
A_Task : My_Task; -- task which needs to finish before more processing
begin
null; -- Just wait until the task is done.
end;
-- Continue other operations here.