comp.lang.ada
 help / color / mirror / Atom feed
From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: Combining entry_call, accept_statment and terminate_statment
Date: Wed, 31 Mar 2004 09:14:12 +0000 (UTC)
Date: 2004-03-31T09:14:12+00:00	[thread overview]
Message-ID: <slrnc6l2v4.nu.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: 4ttk60parnsdj19c34pi38p94uc2rnkj4h@4ax.com

* Dmitry A Kazakov wrote:
> On Tue, 30 Mar 2004 22:47:27 +0000 (UTC), Lutz Donnerhacke
>>My incorrect version was:
>>
>>   protected type Ringbuffer is
>>      procedure Put(data : in String);
>>      procedure Get(data : out Buffer; last : out Extended_Buffer_Offset;
>>        missed : out Absolute_Position; pos : in out Absolute_Position);
>>      function Is_New(pos : Absolute_Position) return Boolean;
>>   private
>>      buf : Buffer;
>>      start, stop : Absolute_Position := Absolute_Position'First;
>>   end Ringbuffer;
>>   
>>   protected type Read_Context(ringbuf : access Ringbuffer) is
>>      entry Get(data : out Buffer; last : out Extended_Buffer_Offset;
>>        missed : out Absolute_Position);
>>   private
>>      pos : Absolute_Position := Absolute_Position'First;
>>   end Read_Context;
>>
>>   protected body Read_Context is
>>      entry Get(
>>        data : out Buffer; last : out Extended_Buffer_Offset;
>>        missed : out Absolute_Position
>>      ) when ringbuf.Is_New(pos) is
>>      begin
>>         ringbuf.Get(data, last, missed, pos);
>>      end Get;
>>   end Read_Context;
>
> Ringbuffer.Get(...); in Read_Context is an external call, so it should
> start a new protected action, which would lead to re-evaluating the
> barriers of ringbuf.all.

There are no barriers on Ringbuffer. The only barrier is on Read_Context.
And the barrier is neither reevaluated on a call to Ringbuffer.Put nor polled.

> So Read_Context.Get would result in re-evaluation of the barriers of both
> objects.

Read_Context.Get is never called after the first evaluation of the barrier.
The barrier is never reevaluated. So the system blocked forever.

> However, I cannot say if ringbuf.Is_New will be called during a
> re-evaluation of the barriers of Read_Context.

It will, but there is no reevaluated at all.

> But surely it won't, if ringbuff is touched from outside.

Ack.

> [ tagged protected object could be very useful in cases like this.
> Mix-in works poorly here. ]

Tagging doesn't provide anything useful in this context.
Please do not mix orthogonal concepts.

Entry families does provide the required behavior:
  An entry family call has two formal argument lists.
  The first one is evaluated before the barrier and therefor usable in the
  barrier itself. (That's the real issue on entry families.)
  The second one is evaluated after the barrier is evaluated to True.



  reply	other threads:[~2004-03-31  9:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-29 19:41 Combining entry_call, accept_statment and terminate_statment Lutz Donnerhacke
2004-03-29 22:04 ` Randy Brukardt
2004-03-29 23:19   ` Mark Lorenzen
2004-03-29 23:14     ` Robert I. Eachus
2004-03-30  7:26   ` Lutz Donnerhacke
2004-03-30 20:04     ` Randy Brukardt
2004-03-30 22:47       ` Lutz Donnerhacke
2004-03-31  9:03         ` Dmitry A. Kazakov
2004-03-31  9:14           ` Lutz Donnerhacke [this message]
2004-03-31 12:22             ` Dmitry A. Kazakov
2004-03-31  6:39       ` Jean-Pierre Rosen
2004-03-30  7:29   ` Lutz Donnerhacke
2004-03-30  8:11     ` tmoran
2004-03-30 11:45     ` Lutz Donnerhacke
2004-03-30  0:33 ` James Rogers
replies disabled

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