From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: task time-out&abort
Date: Thu, 23 Jun 2005 12:59:26 +0200
Date: 2005-06-23T12:59:22+02:00 [thread overview]
Message-ID: <jhadf6lqc0ft.1q4nfc70tvvar$.dlg@40tude.net> (raw)
In-Reply-To: 1119521473.100930.133950@f14g2000cwb.googlegroups.com
On 23 Jun 2005 03:11:13 -0700, e.coli wrote:
> my goal is kill the task if the calculation is long more than 5 sec,.
I would propose to use a more co-operative way than rather brutal aborting
of a task (which is still possible, of course). What about this:
with Ada.Text_IO;
procedure Semplice2 is --processo genitore
task Un_Task is
entry Start; -- Starts calculation
entry Drop_It; -- Aborts calculation
entry Wait_For; -- Waits for the results
end Un_Task;
task body Un_Task is
begin
loop
select
accept Start;
Ada.Text_Io.Put_Line ("Start");
for Iteration in 1..10_000 loop
select
accept Drop_It;
goto Cancel;
else
delay 1.0; -- Doing things
end select;
end loop;
accept Wait_For;
<<Cancel>> null;
or terminate;
end select;
end loop;
end Un_Task;
begin
Un_Task.Start;
Ada.Text_Io.Put_Line ("wait for a horribly long calculation");
select
delay 5.0;
un_task.Drop_It;
Ada.Text_Io.Put_Line ("Horribly long calculation abandoned");
then abort
un_task.Wait_For;
Ada.Text_Io.Put_Line ("Horribly long calculation ready");
end select;
end Semplice2;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2005-06-23 10:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-22 18:08 task time-out&abort e.coli
2005-06-22 18:40 ` Dmitry A. Kazakov
2005-06-23 10:11 ` e.coli
2005-06-23 10:59 ` Dmitry A. Kazakov [this message]
2005-06-22 19:44 ` Mark Lorenzen
2005-06-23 1:44 ` Steve
2005-06-23 15:26 ` e.coli
2005-06-23 17:01 ` e.coli
2005-06-24 11:42 ` Marius Amado Alves
2005-06-28 21:31 ` Robert A Duff
2005-06-29 0:32 ` Marius Amado Alves
2005-06-29 20:52 ` Robert A Duff
2005-07-18 16:11 ` 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