Re: ATC, an example please.
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 11:32:38 +0200
On 30 Jun 2005 01:44:52 -0700, e.coli wrote:
> how ATC work?
ATC transfers control, it does not abort any other task. This is why you
have to explicitly kill the task. Another error in your code is that you
wait not for the calculation completion, but for its initiation.
> can you fix this example,please?
Try this:
with Ada.Text_Io;
procedure Atc_Test is
task A_Task is
entry Start;
entry Ready;
end A_Task;
task body A_Task is
begin
loop
accept Start;
Ada.Text_Io.Put_Line("one.start");
for Iteration in 1..100_0000 loop
Ada.Text_Io.Put (".");
end loop;
accept Ready;
Ada.Text_Io.Put_Line("one.end");
end loop;
end A_Task;
begin
A_Task.Start; -- Initiate calculation
select
delay 2.0; -- After time-out expiration,
abort A_Task; -- kill the task!
Ada.Text_Io.Put_Line ("Long calculation abandoned");
then
abort A_Task.Ready; -- Wait for completion
end select;
Ada.Text_Io.Put_Line ("end main");
end Atc_Test;
----------------------
N.B. This is a wrong way to do things. Don't use ATC if you cannot prove
that there is no other way. Don't abort task, which is even more brutal
than ATC.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: ATC, an example please.
- From: Robert A Duff
- Re: ATC, an example please.
- From: Christoph Grein
- Re: ATC, an example please.
- From: e.coli
- Re: ATC, an example please.
- References:
- ATC, an example please.
- From: e.coli
- ATC, an example please.
- Prev by Date: ATC, an example please.
- Next by Date: Re: ATC, an example please.
- Previous by thread: ATC, an example please.
- Next by thread: Re: ATC, an example please.
- Index(es):
Relevant Pages
|