Escaping the Tyranny of the GC: std.rcstring, first blood

Ola Fosheim Gr via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 15 13:42:28 PDT 2014


On Monday, 15 September 2014 at 19:43:42 UTC, po wrote:
>  Ah, I think I follow.
>
> So in C++ terms:
>  It basically requires either a global shared_ptr, or that you 
> passed one around by reference between threads. And that you 
> then killed it in one thread at the exact moment the control 
> block was read in another thread. That blog post discusses a 
> solution, I wonder if that is implemented in C++'s shared_ptr?

I think you need to either have multiple shared_ptr objects 
(owned by threads) or use atomic_* in cpp?

If I got this right for regular RC you have to increment the 
refcount before handing it to the other thread who is then 
responsible for decrementing it, but if the reference is obtained 
through a global datastructure you need the strong semantics in 
the blog post at 1024cores since you need to increase the count 
to take (thread) ownership of it before accessing it?

(I could be wrong.)


More information about the Digitalmars-d mailing list