comp.lang.ada
 help / color / mirror / Atom feed
From: chad.rmeiners@gmail.com (Chad R. Meiners)
Subject: Re: Synchronizing on multiple distinict resources
Date: 19 Aug 2004 15:18:44 -0700
Date: 2004-08-19T15:18:44-07:00	[thread overview]
Message-ID: <782e906e.0408191418.75299957@posting.google.com> (raw)
In-Reply-To: 1f4ugyz3ig9rc$.785e2wqt1qyg$.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message news:<1f4ugyz3ig9rc$.785e2wqt1qyg$.dlg@40tude.net>...
> >> 1. multiple protected actions / rendezvous (to queue to two chopsticks)
> > 
> > Perhaps something like 
> > 
> > procedure Eat(Left, Right : in out Chop_Stick) is
> >   Synchronize Left and Right;  -- Exclusive access until end of
> > procedure
> > begin
> >   ...
> > end Eat;
> 
> One could allow "free" entry points with normal syntax:
> 
> protected type Chop_Stick is
>    procedure Release; -- A "member" procedure
> private
>    Free : Boolean;
> end Chop_Stick;
>    -- This is not Ada
> entry Seize (Left, Right : in out Chop_Stick);
>    -- Not a "member", but still a primitive operation
> 
> entry Seize (Left, Right : in out Chop_Stick)
>    when Left.Free and Right.Free is
>       -- Dispatching parameters are allowed to appear in barriers
> begin
>    Left.Free  := False;
>    Right.Free := False;
> end Seize;


I think that the when clause isn't even needed since it would need
exclusive access to both left and right.   The question becomes
whether this syntax breaks the encapsulation of the protected types.

For example:

protected type Signal is
  entry Wait;
  procedure Signal;
private
  entry Release;
  On : boolean := false;
end

entry Wait(One, Two : Signal);

protected body Signal is
  entry Wait when not On is
  begin
    requeue Release;
  end Wait;
  procedure Signal is
  begin
    On := true;
  end Signal;
  entry Release when On is
  begin
    On := Release'Count > 0;
  end Release;
end Signal;

entry Wait(One, Two : Signal) when One.On and Two.On is
begin
  null;
end Wait;



  reply	other threads:[~2004-08-19 22:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-02 18:54 Synchronizing on multiple distinict resources Chad R. Meiners
2004-08-02 21:48 ` Jim Rogers
2004-08-03  8:56 ` Dmitry A. Kazakov
2004-08-10 18:51   ` Chad R. Meiners
2004-08-11 13:52     ` Dmitry A. Kazakov
2004-08-19 22:18       ` Chad R. Meiners [this message]
2004-08-20  8:59         ` 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