comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Combining entry_call, accept_statment and terminate_statment
Date: Wed, 31 Mar 2004 11:03:19 +0200
Date: 2004-03-31T11:03:19+02:00	[thread overview]
Message-ID: <4ttk60parnsdj19c34pi38p94uc2rnkj4h@4ax.com> (raw)
In-Reply-To: slrnc6ju7v.t5g.lutz@belenus.iks-jena.de

On Tue, 30 Mar 2004 22:47:27 +0000 (UTC), Lutz Donnerhacke
<lutz@iks-jena.de> wrote:

>* Randy Brukardt wrote:
>> "Lutz Donnerhacke" <lutz@iks-jena.de> wrote in message
>>> That's exactly my current implementation. But I increased the delay and
>>> noticed, that the entry_barrier of the delayed entry_call is evaluated
>>> only once on startup of the timed entry call. If the barrier becomes
>>> true while the delay is running, the delay is not aborted.
>>>
>>> A reason for this strange behavior might be a call to a protected function
>>> in the entry_barrier itself.
>>
>> Barriers of a PO are re-evaluated whenever a protected action ends, and when
>> an entry is called. A barrier which can change state without a protected
>> action ending is incorrect and may not work properly.
>
>So cascading of protected types will not work.

They should, AFAIK.

>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. So Read_Context.Get would result in
re-evaluation of the barriers of both objects. However, I cannot say
if ringbuf.Is_New will be called during a re-evaluation of the
barriers of Read_Context. But surely it won't, if ringbuff is touched
from outside.

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

--
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2004-03-31  9:03 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 [this message]
2004-03-31  9:14           ` Lutz Donnerhacke
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