comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <Nick.Roberts@dial.pipex.com>
Subject: Re: task finished?
Date: 1998/05/17
Date: 1998-05-17T00:00:00+00:00	[thread overview]
Message-ID: <6jmf3b$h3a$1@plug.news.pipex.net> (raw)
In-Reply-To: 01bc620a$7efdf9a0$LocalHost@default


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)







  parent reply	other threads:[~1998-05-17  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-16  0:00 task finished? Markus Falsinger
1998-05-16  0:00 ` Matthew Heaney
1998-05-17  0:00 ` Nick Roberts [this message]
1998-05-17  0:00 ` Tom Moran
replies disabled

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