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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fb45e48e8dddeabd X-Google-Attributes: gid103376,public X-Google-Thread: ffc1e,fb45e48e8dddeabd X-Google-Attributes: gidffc1e,public From: kaz@ashi.footprints.net (Kaz Kylheku) Subject: Re: Ada Protected Object Tutorial #1 Date: 1999/12/16 Message-ID: #1/1 X-Deja-AN: 561323651 Cache-Post-Path: ashi.FootPrints.net!unknown@localhost References: <839toq$pu$1@bgtnsc03.worldnet.att.net> X-Complaints-To: abuse@direct.ca X-Trace: brie.direct.ca 945331347 204.239.179.1 (Thu, 16 Dec 1999 00:02:27 PST) Organization: Psycho-Neurotic Institute for The Very, Very Nervous X-Cache: nntpcache 2.3.3b3 (see http://www.nntpcache.org/) User-Agent: slrn/0.9.5.7 (UNIX) Reply-To: kaz@ashi.footprints.net NNTP-Posting-Date: Thu, 16 Dec 1999 00:02:27 PST Newsgroups: comp.programming.threads,comp.lang.ada Date: 1999-12-16T00:00:00+00:00 List-Id: On Wed, 15 Dec 1999 22:27:17 -0700, James S. Rogers wrote: >This is the first of hopefully several examples of uses for Ada Protected >Objects. [ snip ] >Protected Procedures: > >Protected procedures are typically used to alter the value of one or more >data >components in a protected object. The parameters of a protected procedure >may have the "IN" mode, like functions. They may also have "OUT" mode, >indicating that the value is write only, or "IN OUT" mode indicating that >the >parameter value can be read and updated. Only one task at a time may >execute a protected procedure. Protected functions cannot access the >protected object while it is being accessed by a protected procedure. What if a protected procedure of an object calls another protected procedure? Presumably this is allowed, which means that some recursive lock has to be used for the implementation, or else the compiler has to generate code that passes around secret ``already locked'' flags into procedures. How does the user of the protected object compose atomic operations? This approach to design is generally wasteful. It's more reasonable to have public methods which always lock and unlock, and unprotected methods which assume that an object is already locked. It's also useful for an object to expose lock and unlock methods, and expose unprotected operations, so that the user of the object can compose a sequence of operations into an indivisible block. >Protected Entries: > >Protected entries are just like protected functions with one small >difference. >Protected entries block untils a boundary condition becomes true. For >example, you would use a protected entry to read from a protected >bounded queue. The entry would block as long as the queue was empty. What if you want to block for something in the middle of the critical region? I assume that you can call a protected entry from within a protected procedure. Could you expand on what flexibilities there exist within this framework?