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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Safety of unprotected concurrent operations on constant objects Date: Tue, 6 May 2014 14:19:33 +0200 Organization: cbb software GmbH Message-ID: References: <7403d130-8b42-43cd-a0f1-53ba34b46141@googlegroups.com> <6c2cd5d4-a44c-4c18-81a3-a0e87d25cd9e@googlegroups.com> <83ha6vuynrzs.1jk08faxb8mnl.dlg@40tude.net> <97a0996a-a593-4990-95e9-44f4e9070fd3@googlegroups.com> <5368b00d$0$6703$9b4e6d93@newsspool3.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: G+aXx1XI67D34t54ibhUPQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:19711 Date: 2014-05-06T14:19:33+02:00 List-Id: On Tue, 06 May 2014 11:49:01 +0200, G.B. wrote: > If the program uses containers only to provide some internal > storage, then it will naturally shield them. Its own > data structures (tagged types, say) will only Have-A container, > and not emphasize the container operations. In this case, I think, > it is adequate to let the programmer place mutex as needed. > (Even re-entrant (owned) semaphores incur some overhead.) The issues with this low-level approach are multiple: 1. It is very simple to forget to place mutex in some operation and get a very nasty bug to find. 2. A language-supported mechanism does not dictate certain implementation. The compiler may choose monitor instead of mutex or scheduling technique to achieve the goal in most effective manner. 3. The low-level approach breaks under inheritance especially when overriding must call to the parent type operations. 4. The low-level approach breaks encapsulation. If you add new operations you must expose the mutex to them. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de