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: a07f3367d7,8e1d11d5f7e1eb9b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news4.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.84.MISMATCH!xlned.com!feeder1.xlned.com!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Status of AdaCL: Ada Class Library Followup-To: comp.lang.ada Date: Thu, 25 Feb 2010 15:16:17 +0100 Message-ID: <7unf1hF7anU1@mid.individual.net> References: <05a58751-7a13-48d6-9080-91322817bfe8@t32g2000pre.googlegroups.com> <7ue685FpluU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: individual.net F1NwMGcG8WxljaAtvBJeWwZ+r/G/fZXncaKAODGXw3HdgeuwI= Cancel-Lock: sha1:icZ9AODx46XRYLT6njN1KAiNl5k= User-Agent: KNode/4.4 Xref: g2news1.google.com comp.lang.ada:9321 Date: 2010-02-25T15:16:17+01:00 List-Id: Stephen Leake wrote: > "Randy Brukardt" writes: > >> Am 22.02.2010, 02:51 Uhr, schrieb Björn Persson : >> >>> I had intended to switch from Charles to Ada.Containers, but I changed >>> my mind when I learned that Ada.Containers can't even be read by >>> multiple >> > tasks at once. >> >> For the record, we've studied this several times and have always >> concluded that hidden synchronization is dangerous. That is, >> synchronization should be explicit. Beyond that, it is impossible to come >> up with a reasonable definition of what should be locked -- it really >> depends on the use of the containers. > > I agree with this, but I think the OP was implying that you needed > locking even for read-only access of Ada.Containers from multiple > tasks; is that true? I don't see why it should be; each task declares > its own cursors, which don't interfere with each other. I think that the downward closure subprograms update some flags inside the container. E.g., in gnat doubly linked lists, within the Query_Element: procedure Query_Element (Position : Cursor; Process : not null access procedure (Element : Element_Type)); Pretty read-only, it seems, but inside you find: declare C : List renames Position.Container.all'Unrestricted_Access.all; B : Natural renames C.Busy; L : Natural renames C.Lock; begin B := B + 1; L := L + 1; (...) So, basically, yes, even certain read-only uses are not thread-safe (Element would be, at least in gnat implementation). Never though of this before, but even wrapping a call to that in a protected function would be dangerous, since protected functions are concurrent? And that's a procedure with only "in" arguments, which would be callable from such a function. Am I right here?