comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: task time-out&abort
Date: Wed, 22 Jun 2005 18:44:34 -0700
Date: 2005-06-22T18:44:34-07:00	[thread overview]
Message-ID: <UZKdna9OFNsujiffRVn-1Q@comcast.com> (raw)
In-Reply-To: 1119463703.048124.135330@o13g2000cwo.googlegroups.com

If you just want to see Asynchronous Transfer of control in action, change 
your example to read:

   task body Un_Task is
   begin
      loop
         select
            accept Uno do
               Ada.Text_Io.Put_Line("foo");
            end Uno;
             loop           -- ;)
                delay(0.0);
             end loop;
         or
            accept Due do
               Ada.Text_Io.Put_Line("buffering");
               Ada.Text_Io.Put_Line("bar");
            end Due;
         end select;
      end loop;
   end Un_Task;

Note: I didn't test this to verify, but I think it will give you the result 
you're looking for.
Uno starts the long operation.  Since the task will not go back to the 
select until the loop is done, your abort should kick in.

Also...
  In my informal view of things, you should minimize the amount of work you 
do inside of an accept block.  During the rendevous, only one of the tasks 
is active, so it kind of defeats the purpose of using a separate task.  In 
fact you could change your example task to:

   task body Un_Task is
   begin
      loop
         select
            accept Uno;
            Ada.Text_Io.Put_Line("foo");
             loop           -- ;)
                delay(0.0);
             end loop;
         or
            accept Due;
            Ada.Text_Io.Put_Line("buffering");
            Ada.Text_Io.Put_Line("bar");
         end select;
      end loop;
   end Un_Task;

Which completely eliminates any work done inside the accept block.

Steve
(The Duck) 





  parent reply	other threads:[~2005-06-23  1:44 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
2005-06-22 19:44 ` Mark Lorenzen
2005-06-23  1:44 ` Steve [this message]
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