From: jsa@alexandria (Jon S Anthony)
Subject: Re: How to wait for task completion
Date: 1996/09/16
Date: 1996-09-16T00:00:00+00:00 [thread overview]
Message-ID: <JSA.96Sep16170139@alexandria> (raw)
In-Reply-To: 01bba2e8$c45aad90$35208b82@wd
In article <01bba2e8$c45aad90$35208b82@wd> "wiljan" <W.Derks@nl.cis.philips.com> writes:
> Is there a simply way to wait until a task has completed in Ada?
> I have a pointer to a task type:
> task type tsk;
> type ptsk is access tsk;
> p:ptsk;
> At a certain point I want to clean up the resources that the task is
> using but this can only be done when the task is completed.
Depending on your needs and constraints, the simplest trick would be:
in some code where you require P,
...
declare
type Ptsk is access Tsk; -- Put access type here to make block master
P : Ptsk;
...
begin
null;
end; -- Wait until
You can also put the block in another "parent" task to avoid blocking
the whole program (if that is desirable and deemed "cheap" enough).
For example:
with Text_IO;
with Objs; use Objs;
procedure Wait_Ex is
task type Tks;
task body Tks is
begin
for I in 1..20 loop
delay 0.1;
Text_IO.Put_Line("Hi" & Integer'Image(i));
end loop;
end;
begin
declare
type Ptsk is access Tks;
T : Ptsk := new Tks;
begin
null;
end;
Text_IO.Put_Line("Done");
end Wait_Ex;
$ gnatmake wait_ex.adb
$ wait_ex.adb
Hi 1
Hi 2
Hi 3
Hi 4
Hi 5
Hi 6
Hi 7
Hi 8
Hi 9
Hi 10
Hi 11
Hi 12
Hi 13
Hi 14
Hi 15
Hi 16
Hi 17
Hi 18
Hi 19
Hi 20
Done
$
--
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178
617.484.3383
jsa@organon.com
prev parent reply other threads:[~1996-09-16 0:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-09-15 0:00 How to wait for task completion wiljan
1996-09-15 0:00 ` David C. Hoos, Sr.
1996-09-20 0:00 ` Stephen & Tammy House
1996-09-15 0:00 ` Samuel Tardieu
1996-09-16 0:00 ` wiljan
1996-09-17 0:00 ` Ted Dennison
1996-09-17 0:00 ` Samuel Tardieu
1996-09-17 0:00 ` Norman H. Cohen
1996-09-17 0:00 ` wiljan
1996-09-18 0:00 ` Tucker Taft
1996-09-18 0:00 ` Norman H. Cohen
1996-09-17 0:00 ` wiljan
1996-09-18 0:00 ` Jon S Anthony
1996-09-16 0:00 ` Jon S Anthony [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox