comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Problem with task component
Date: Mon, 24 Sep 2012 18:29:57 +0200
Date: 2012-09-24T18:29:57+02:00	[thread overview]
Message-ID: <1gq5enrpptnql.v7pdz1umht4a$.dlg@40tude.net> (raw)
In-Reply-To: a1904722-089b-41f5-a4a1-2216a5471e8a@googlegroups.com

On Mon, 24 Sep 2012 08:44:32 -0700 (PDT), Adam Beneschan wrote:

> (2) Off the top of my head, I don't see any *implementation* reason why a
> selective accept couldn't have both a delay alternative and a terminate
> alternative.

Else-alternative is no less important than delay. We need something like

   select
      terminate; -- Terminate if requested otherwise continue
   else
      null;
   end select;

> It seems like it wouldn't require the runtime library to do anything it
> doesn't already know how to do.

There is also a lesser issue with terminate. It does not allow a sequence
of statements to execute before termination. The workaround requires quite
clumsy constructs involving controlled types.

--------
I thought about a predefined task entry T'Terminate to determine if
termination requested. It would resolve most of the problems the terminate
alternative has.

We would simply write:

task body T is
begin
   loop
      select
         accept T'Terminate;
         exit;
      or ... whatever
      end select;
   end loop;
end T;

T'Terminate would never be dequeued, i.e. could be accepted as many times
as necessary.

If allowed to be called explicitly, it could also be used as an unobtrusive
task abort request, with the advantage that it could be requested using a
timed entry call:

   select
      T'Terminate;
   or delay 1.0;
      Put_Line ("Something is wrong with T");
      abort T; -- Die already, dog!
   end select;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2012-09-29 19:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 18:22 Problem with task component Simon Wright
2012-09-19 18:48 ` Dmitry A. Kazakov
2012-09-19 20:40   ` Simon Wright
2012-09-19 21:11     ` Dmitry A. Kazakov
2012-09-19 21:48       ` Simon Wright
2012-09-24  5:28         ` J-P. Rosen
2012-09-24  8:23           ` Simon Wright
2012-09-24 13:37             ` J-P. Rosen
2012-09-24 14:17               ` Simon Wright
2012-09-24 17:53               ` Robert A Duff
2012-09-24 20:40                 ` J-P. Rosen
2012-09-24 15:44             ` Adam Beneschan
2012-09-24 16:13               ` AdaMagica
2012-09-24 16:43                 ` Adam Beneschan
2012-09-24 16:29               ` Dmitry A. Kazakov [this message]
2012-09-24 20:49                 ` J-P. Rosen
2012-09-25  7:35                   ` Dmitry A. Kazakov
2012-09-25 17:52                     ` J-P. Rosen
2012-09-25 18:35                       ` Dmitry A. Kazakov
2012-09-25 19:22                         ` J-P. Rosen
2012-09-26  7:27                           ` Dmitry A. Kazakov
2012-09-26 11:49                             ` Georg Bauhaus
2012-09-26 14:13                               ` Dmitry A. Kazakov
2012-09-19 19:44 ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox