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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,16594902ce57591b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread4.news.pas.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: Matthew Heaney@MHEANEYIBMT43 Newsgroups: comp.lang.ada Subject: Re: Multitasking and containers References: From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 24 Nov 2006 12:12:13 GMT NNTP-Posting-Host: 4.238.121.243 X-Complaints-To: abuse@earthlink.net X-Trace: newsread4.news.pas.earthlink.net 1164370333 4.238.121.243 (Fri, 24 Nov 2006 04:12:13 PST) NNTP-Posting-Date: Fri, 24 Nov 2006 04:12:13 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news2.google.com comp.lang.ada:7688 Date: 2006-11-24T12:12:13+00:00 List-Id: Maciej Sobczak writes: > That would be interesting, but would break apart when encapsulated within a > protected object, because there multiple readers would be allowed. But I think that's true only when multiple readers are calling protected functions. (There is a subtle difference in semantics between protected functions and protected procedures.) It does seem you'd need to use a protected procedure when manipulating a container nested inside a protected object, since a protected function wouldn't provide the level of synchronization required. > Having a mutex for readers sounds like a concurrency killer and relying on > protected wrappers seems to be fragile because of this possible > mutability. So - what is The Solution (tm) for multiple tasks reading from > the same container? Declare the container object inside a protected object, and use protected procedures to manipulate the container. Protected wrappers should be fine, as long as you use protected procedures, not protected functions. > Let's say you want to have N worker tasks consulting a shared dictionary > (map) that was initialized before the tasks started their work. How would you > solve this? As above: declare the container object inside a protected object, and use protected procedures to manipulate the container.