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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.133.102 with SMTP id h99mr2303191iod.134.1507475412581; Sun, 08 Oct 2017 08:10:12 -0700 (PDT) X-Received: by 10.157.15.100 with SMTP id 91mr133478ott.4.1507475412550; Sun, 08 Oct 2017 08:10:12 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!k70no733354itk.0!news-out.google.com!194ni2909itf.0!nntp.google.com!k70no733351itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 8 Oct 2017 08:10:12 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=85.167.108.83; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR NNTP-Posting-Host: 85.167.108.83 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Task safe containers? Help needed. From: reinert Injection-Date: Sun, 08 Oct 2017 15:10:12 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:48396 Date: 2017-10-08T08:10:12-07:00 List-Id: About your first option: Putting the containers in a protected object makes the container functions "private" and not directly available outside the protected object. Right? I like these container functions. But your other options also somehow complicates :-) A compromise seems to be necessary :-) Maybe the first option anyway facilitates cleanest code? There must be a reason for the invention of protected types. reinert On Sunday, October 8, 2017 at 8:57:18 AM UTC+2, Dmitry A. Kazakov wrote: > On 2017-10-08 06:27, reinert wrote: > > > if I want to access a container (Vector, Set, Map) by several tasks > > (updating and reading) - (hopefully) without loosing functionality of > > the container. > > > > What should I do? > > 1. If operations are short and non-blocking put the container in a > protected object and route operations trough object's ones. > > 2. If operations are long, unbounded, blocking (most of the cases): > > 2.a Use a mutex taken at the beginning of each operation and released at > the end. > > 2.b Use monitor task owning the container. All operations are performed > by the task from task's entries. > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de