comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Advice, tasking and hardware
Date: Fri, 27 May 2016 21:13:12 -0700
Date: 2016-05-27T21:13:12-07:00	[thread overview]
Message-ID: <nib5ls$f41$1@dont-email.me> (raw)
In-Reply-To: <2c0dfaf8-9344-4b9c-87b4-12de687687ce@googlegroups.com>

On 05/27/2016 05:25 PM, rieachus@comcast.net wrote:
> 
> package Shutdown is
>   task Suspend is
>     entry Stop;
>     entry Wait;
>   end Suspend;
> end Shutdown;
> ...
> package body Shutdown is
> begin
>  task body Suspend is
>  begin
>    accept Stop;
>    loop
>      select
>        accept Wait;
>      or
>        accept Stop; -- in case of multiple calls to Stop.
>      or
>        terminate;
>      end select;
>    end loop;
>  end Shutdown;

Is there any reason for this to be a task? I've always used a protected object:

package Shutdown is
   protected Control is
      procedure Time_To_Die;
      -- Tell the system to shut down

      function Time_To_Die return Boolean;
      -- Returns True if the system is shutting down

      entry Wait;
      -- Blocks until the system is shutting down
   private -- Control
      Shutting_Down : Boolean := False;
   end Control;
end Shutdown;

Procedure Time_To_Die sets Shutting_Down to True, function Time_To_Die returns
Shutting_Down, and Wait is null and has the barrier "when Shutting_Down".
Procedure Time_To_Die and Wait work the same as Stop and Wait. The function is
useful for sporadic tasks that block on an entry waiting for something to do.

-- 
Jeff Carter
"I'm a kike, a yid, a heebie, a hook nose! I'm Kosher,
Mum! I'm a Red Sea pedestrian, and proud of it!"
Monty Python's Life of Brian
77


  parent reply	other threads:[~2016-05-28  4:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25 21:24 Advice, tasking and hardware patrick
2016-05-26  1:09 ` Jeffrey R. Carter
2016-05-26  8:13   ` Simon Wright
2016-05-26  7:26 ` Dmitry A. Kazakov
2016-05-26 16:41   ` patrick
2016-05-26 17:56     ` Dmitry A. Kazakov
2016-05-26 20:35     ` Jeffrey R. Carter
2016-05-26 19:35   ` Jeffrey R. Carter
2016-05-26 20:51     ` patrick
2016-05-27  7:50     ` Dmitry A. Kazakov
2016-05-27 18:00       ` Simon Wright
2016-05-27 19:06       ` Jeffrey R. Carter
2016-05-27 22:05         ` Randy Brukardt
2016-05-27 23:09           ` Jeffrey R. Carter
2016-05-27 19:13       ` Shark8
2016-05-27 20:27         ` Dmitry A. Kazakov
2016-05-27 22:27           ` Randy Brukardt
2016-05-28  6:49             ` Dmitry A. Kazakov
2016-05-28 14:38           ` Shark8
2016-05-28 15:45             ` Dmitry A. Kazakov
2016-05-28  0:25 ` rieachus
2016-05-28  1:57   ` patrick
2016-05-28  4:13   ` Jeffrey R. Carter [this message]
2016-06-01 14:37     ` rieachus
2016-06-01 19:09       ` Dmitry A. Kazakov
2016-06-06  3:33         ` rieachus
2016-06-06  7:18           ` Dmitry A. Kazakov
2016-06-07 16:53             ` rieachus
2016-06-07 20:21               ` Dmitry A. Kazakov
2016-06-08  4:06                 ` rieachus
2016-06-08  7:29                   ` Dmitry A. Kazakov
2016-06-08 12:56                     ` rieachus
2016-06-08  0:19               ` Dennis Lee Bieber
replies disabled

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