From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d87fcae02ce5c10a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews2.google.com!not-for-mail From: chad.rmeiners@gmail.com (Chad R. Meiners) Newsgroups: comp.lang.ada Subject: Re: Synchronizing on multiple distinict resources Date: 19 Aug 2004 15:18:44 -0700 Organization: http://groups.google.com Message-ID: <782e906e.0408191418.75299957@posting.google.com> References: <7ebaa24d.0408021054.4abc6e73@posting.google.com> <782e906e.0408101051.5e122af0@posting.google.com> <1f4ugyz3ig9rc$.785e2wqt1qyg$.dlg@40tude.net> NNTP-Posting-Host: 24.11.216.156 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1092953924 26647 127.0.0.1 (19 Aug 2004 22:18:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 19 Aug 2004 22:18:44 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:2879 Date: 2004-08-19T15:18:44-07:00 List-Id: "Dmitry A. Kazakov" 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;