From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: DYNAMIC ADA TASK CREATION?
Date: Wed, 18 Jun 2003 06:11:30 GMT
Date: 2003-06-18T06:11:30+00:00 [thread overview]
Message-ID: <3EF0026E.2050309@attbi.com> (raw)
In-Reply-To: x7vadcgwiyo.fsf@smaug.pushface.org
Simon Wright wrote:
>> How to create dynamic for example N tasks. I don't know how create N of
>>tasks and array (not list). For example user interface gets an Integer (N)
>>from user and then we create N number of Task in ADA. How to do this?Can
>>anybody help me?
>
>
> (uncompiled)
>
> task type t is
> -- some entries
> end t;
>
> task body t is
> begin
> -- code
> end t;
>
> type ts is array (positive range <>) of t;
>
> n : positive;
>
> begin
>
> -- read in n
>
> declare
> the_ts : ts (1 .. n);
> begin
> -- do something with the tasks
> -- NB, can't pass this point until all the tasks have terminated
> end;
Correct. But if you don't want to get stuck there, do this instead:
-- task type t as above
type ta is access t;
type ts is array (positive range <>) of ta := new t;
n : positive;
begin
-- read in n
declare
the_ts : ts (1 .. n);
begin
-- do something with the tasks
-- NB, CAN pass this once all the tasks have been created.
end;
For an ordinary task object, the creator of the object is the master (in
the original example, a declare block. But for a task created by an
allocator, the place where the access type was declared determines who
is the master. (In either case, if that is in a library package, the
master is the environment task.)
next prev parent reply other threads:[~2003-06-18 6:11 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-17 19:53 DYNAMIC ADA TASK CREATION? avram
2003-06-17 20:24 ` Simon Wright
2003-06-18 6:11 ` Robert I. Eachus [this message]
2003-06-18 9:20 ` Georg Bauhaus
2003-06-18 11:13 ` John McCabe
2003-06-18 12:43 ` John McCabe
2003-06-18 14:17 ` Georg Bauhaus
2003-06-19 5:07 ` Simon Wright
2003-06-19 6:05 ` Robert I. Eachus
2003-06-19 23:30 ` Jeffrey Carter
2003-06-18 19:15 ` avram
2003-06-18 21:17 ` Craig Carey
2003-06-20 18:56 ` avram
2003-06-21 13:06 ` Pascal Obry
2003-06-18 23:28 ` Robert I. Eachus
2003-06-19 5:09 ` Simon Wright
2003-06-19 6:39 ` Robert I. Eachus
2003-06-19 20:34 ` Simon Wright
2003-06-28 0:54 ` Matthew Heaney
2003-06-28 7:25 ` Robert I. Eachus
2003-06-30 7:35 ` Dmitry A. Kazakov
2003-06-30 15:01 ` Matthew Heaney
2003-07-01 7:19 ` Dmitry A. Kazakov
2003-07-01 14:21 ` Matthew Heaney
2003-07-02 12:05 ` Mário Amado Alves
2003-07-02 19:41 ` Simon Wright
2003-07-03 21:31 ` Mário Amado Alves
2003-07-03 9:53 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox