comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to make a task wait and resume ?
Date: Thu, 17 Jan 2019 18:28:53 +0100
Date: 2019-01-17T18:28:53+01:00	[thread overview]
Message-ID: <q1qe0o$1te0$1@gioia.aioe.org> (raw)
In-Reply-To: 949cfe5a-38ee-49bc-81c6-4fa8e4223289@googlegroups.com

On 2019-01-17 17:21, reinert wrote:

> I have used a protected object to control (from "outside")
> wait/resume of a task. It works, but is it good practise?

Why not? In other cases you might use a task entry instead of protected 
object.

What you did is a manual reset event. For your case a pulse event might 
work better:

    entry wait1 when OK is
    begin
       OK := False;
    end wait1;

If the pulse event to release several tasks it is a bit more 
complicated. An example is in the Simple Components.

Then there is usually task exit condition involved. So the pattern might be:

    entry wait1 when OK or else Exit_Requested is
    begin
       if Exit_Requested then
          raise End_Error;
       else
          OK := False;
       end if;
    end wait1;

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

  reply	other threads:[~2019-01-17 17:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 16:21 How to make a task wait and resume ? reinert
2019-01-17 17:28 ` Dmitry A. Kazakov [this message]
2019-01-17 22:28   ` Randy Brukardt
2019-01-18  7:59     ` reinert
2019-01-18 10:20       ` Dmitry A. Kazakov
replies disabled

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