comp.lang.ada
 help / color / mirror / Atom feed
* task finished?
@ 1998-05-16  0:00 Markus Falsinger
  1998-05-16  0:00 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Markus Falsinger @ 1998-05-16  0:00 UTC (permalink / raw)



I have created a number of tasks, but to continue with a procedure I have
to wait until they all have terminated. How can I check whether they all
have terminated or not? (They all have the same name, created in a loop)

Thanks, Markus




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: task finished?
  1998-05-16  0:00 task finished? Markus Falsinger
@ 1998-05-16  0:00 ` Matthew Heaney
  1998-05-17  0:00 ` Tom Moran
  1998-05-17  0:00 ` Nick Roberts
  2 siblings, 0 replies; 4+ messages in thread
From: Matthew Heaney @ 1998-05-16  0:00 UTC (permalink / raw)



In article <01bc620a$7efdf9a0$LocalHost@default>, "Markus Falsinger"
<benno@forfree.at> wrote:

(start of quote)
I have created a number of tasks, but to continue with a procedure I have
to wait until they all have terminated. How can I check whether they all
have terminated or not? (They all have the same name, created in a loop)
(end of quote)

There is an attribute, T'Terminated.

Normally, however, you don't create tasks in a dynamic scope as a
subprogram.  What are you trying to do?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: task finished?
  1998-05-16  0:00 task finished? Markus Falsinger
  1998-05-16  0:00 ` Matthew Heaney
  1998-05-17  0:00 ` Tom Moran
@ 1998-05-17  0:00 ` Nick Roberts
  2 siblings, 0 replies; 4+ messages in thread
From: Nick Roberts @ 1998-05-17  0:00 UTC (permalink / raw)



Tasks created through access types ... commence activation immediately upon
evaluation of the allocator whether it occurs in a sequence of statements or
an initial value ... activation is completed before the allocator returns
with the access value. Furthermore, such tasks are not dependent upon the
unit where they are created but are dependent on the block, subprogram body,
or task body containing the declaration of the access type itself.
[Programming in Ada 95, John Barnes; Addison-Wesley 1996]

So, all you have to do is to put the declaration of the access type which
access your tasks immediately in the block you want to be synchronised with
their termination. For example:

procedure Firework_Display is
    task type Firework_Controller is
        ...
    end;
    type Controller_Access is access Firework_Controller;
    FA: array (1..200) of Controller_Access;
begin
    for i in 1..200 loop
        FA(i) := new Firework_Controller;
    end loop;
end Firework_Display;

By the time a call to the procedure Firework_Display returns, all the
Firework_Controller tasks have terminated. This is because their access
type, Controller_Access, is declared within the Firework_Display procedure,
so all the tasks (allocated to this access type) are dependent on the
Firework_Display procedure.

Note that the entire loop could have been omitted by initialising the FA
array with (others => new Firework_Controller). Behaviour would be the same,
in this case.

[Must dash now to cook the dinner!]

--
Nick Roberts
ThoughtWing Software, Croydon, UK
ThoughtWing@dial.pipex.com

Markus Falsinger wrote in message <01bc620a$7efdf9a0$LocalHost@default>...
|I have created a number of tasks, but to continue with a procedure I have
|to wait until they all have terminated. How can I check whether they all
|have terminated or not? (They all have the same name, created in a loop)







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: task finished?
  1998-05-16  0:00 task finished? Markus Falsinger
  1998-05-16  0:00 ` Matthew Heaney
@ 1998-05-17  0:00 ` Tom Moran
  1998-05-17  0:00 ` Nick Roberts
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Moran @ 1998-05-17  0:00 UTC (permalink / raw)



> I have to wait until they all have terminated
Can you just create them all in a scope, as opposed to globablly,  so
that scope exit is where you will wait till they are all done?




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-05-17  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-16  0:00 task finished? Markus Falsinger
1998-05-16  0:00 ` Matthew Heaney
1998-05-17  0:00 ` Tom Moran
1998-05-17  0:00 ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox