comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Freezing a task
Date: Thu, 17 Nov 2011 17:53:42 +0100
Date: 2011-11-17T17:53:42+01:00	[thread overview]
Message-ID: <1mvy349lkn3wg$.1dxam3tmlwr6l$.dlg@40tude.net> (raw)
In-Reply-To: mzm6z5dir1ee$.1b36kl4upye4x$.dlg@40tude.net

On Thu, 17 Nov 2011 17:22:57 +0100, Dmitry A. Kazakov wrote:

>    Paused : Boolean := False;
> begin
>    loop
>       if Paused then
>          accept Release;
>          Paused := False;
>       else
>          select
>             accept Pause;
>             Paused := True;
>          else
>             ... -- Do stuff
>          end select;
>       end if;
>    end loop;

P.S. there is a deadlock in above if improperly used from outside. It is
simple to fix.

It is worth to note that one of the rationales behind protected objects
introduced in Ada 95, was to ease things like above. The same done with a
protected object would be simpler, safer and reusable (within the task)
too.

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



  reply	other threads:[~2011-11-17 16:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-17 15:33 Freezing a task Rego, P.
2011-11-17 16:00 ` Simon Wright
2011-11-17 16:22   ` Dmitry A. Kazakov
2011-11-17 16:53     ` Dmitry A. Kazakov [this message]
2011-11-17 18:27     ` Simon Wright
2011-11-18  1:23     ` Rego, P.
2011-11-18  6:04       ` Jeffrey Carter
2011-11-18  8:47       ` Dmitry A. Kazakov
2011-11-18 10:05         ` Simon Wright
2011-11-18 11:41           ` Georg Bauhaus
2011-11-18 13:42             ` Dmitry A. Kazakov
2011-11-17 16:00 ` Dmitry A. Kazakov
2011-11-17 16:53   ` stefan-lucks
2011-11-17 17:08     ` Dmitry A. Kazakov
2011-11-17 17:13 ` Adam Beneschan
2011-11-17 18:01   ` AdaMagica
2011-11-18  1:22   ` Rego, P.
2011-11-17 17:34 ` Jeffrey Carter
2011-11-18  1:34   ` Rego, P.
2011-11-18  8:56     ` Dmitry A. Kazakov
2011-11-18  7:24 ` anon
2011-11-18 22:25   ` Anh Vo
2011-11-19  7:37     ` anon
2011-11-22  1:58   ` Rego, P.
replies disabled

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