comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Assignment with Adjust and Task Safety
Date: Tue, 22 Mar 2016 14:14:40 -0500
Date: 2016-03-22T14:14:40-05:00	[thread overview]
Message-ID: <ncs5j1$1gg$1@loke.gir.dk> (raw)
In-Reply-To: ncs46a$qo2$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:ncs46a$qo2$1@gioia.aioe.org...
...
> You add a mutex, global or of a narrower scope, and take it in Adjust and 
> Finalize before doing anything else with the pointer.
>
> I don't do this in my implementation of smart pointers because I consider 
> it not worth the overhead of two protected actions for being protected 
> against concurrent access to the pointer. [*]
>
> The rationale is this. Smart pointers are unlikely shared. Normally they 
> are kept in containers that are not shared or else are protected by a 
> mutex, which eliminates the problem.

Right. And notice that this performance tradeoff and rationale applies to 
virtually every library that one could imagine. For instance, it applies to 
the entire standard Ada runtime. Unless a library advertises that it works 
with task shared variables (like Ada.Containers.Unbounded_Priority_Queues), 
one should always assume it does not work without protection. (Usually, a 
"task-safe" library just ensures that *different* variables can be operated 
on by different tasks - even that can be hard to support, as in Claw.)

For future Ada, we're looking at ways to decrease the danger from shared 
variables, especially in the context of parallel loops and the like. It is 
probably the biggest danger in Ada, given that it cannot be tested for 
(given that very specific conditions have to happen for there to be a 
failure, the vast majority of the time there is no problem) and that the 
effects of violating 9.10 can be catostrophic.

                                 Randy.





  reply	other threads:[~2016-03-22 19:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 14:36 Assignment with Adjust and Task Safety Jeremiah
2016-03-22 17:40 ` Shark8
2016-03-22 18:50 ` Dmitry A. Kazakov
2016-03-22 19:14   ` Randy Brukardt [this message]
2016-03-26  1:31   ` Jeremiah
2016-03-26 21:27   ` J-P. Rosen
2016-03-22 23:17 ` rieachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox