comp.lang.ada
 help / color / mirror / Atom feed
From: Darren New <dnew@san.rr.com>
Subject: Re: Requeue
Date: Tue, 09 Apr 2002 16:01:00 GMT
Date: 2002-04-09T16:01:00+00:00	[thread overview]
Message-ID: <3CB3105C.740A3B18@san.rr.com> (raw)
In-Reply-To: 3CB0CD37.52B43088@yahoo.com

Anatoly Chernyshev wrote:
> Could someone post a simple yet practical example of using that
> statement in Ada programming?

Part of the need for requeue comes from the fact that a guard can't be
based on the parameters of the call. So if I want to do something like

  entry Save_In_Buffer(Octets : in Stream_Element_Array) 
    when Octets'Length < My_Buffer.Remaining_Space is
  begin .... end Save_In_Buffer;

I can't do that. Octets'Length isn't allowed in the guard.
So instead I do
  entry Save_In_Buffer(...)
    when True is
  begin
    if My_Buffer.Remaining_Space < Octets'Length then
      requeue Save_Wait
    end if;
    ...
  end Save_In_Buffer;

Then Save_Wait has a guard that is gets set to false whenever I put
something into the buffer and true whenever I take something out. Inside
Save_Wait, once you get in, you check again, and if there's still no
room, you requeue once again. Ugly but it works.

I'd be happy to put the code somewhere if you want to look.

-- 
Darren New 
San Diego, CA, USA (PST). Cryptokeys on demand.
      Remember, drive defensively if you drink.



  parent reply	other threads:[~2002-04-09 16:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-07 22:50 Requeue Anatoly Chernyshev
2002-04-08  3:40 ` Requeue Pat Rogers
2002-04-08  5:00 ` Requeue Robert Dewar
2002-04-09 10:27   ` Requeue Ehud Lamm
2002-04-09 16:01 ` Darren New [this message]
2002-04-09 17:52 ` Requeue Anatoly Chernyshev
2002-04-09 18:28   ` Requeue Larry Kilgallen
2002-04-09 20:06     ` Requeue Anatoly Chernyshev
2002-04-09 20:47       ` Requeue Marin David Condic
2002-04-09 21:15       ` Requeue Pat Rogers
2002-04-09 21:43         ` Requeue Anatoly Chernyshev
2002-04-10  2:18           ` Requeue Pat Rogers
2002-04-09 21:22       ` Requeue Ehud Lamm
replies disabled

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