Precise GC state

Ola Fosheim Grostad ola.fosheim.grostad at gmail.com
Mon Nov 27 07:03:01 UTC 2017


On Monday, 27 November 2017 at 06:47:00 UTC, Dmitry Olshansky 
wrote:
> Last time I check shared_ptr can be safely shared across 
> threads, hence RC is takling synchronization and most likely 
> atomics since locks won’t be any better.

The controlblock can, but it is crazy to use shared_ptr for 
anything more than high level ownership. It is a general solution 
with weak pointers and extra indirection, not a typical RC 
implementation for datastructures.

>> In C++ sync is manual, which is the only efficient way to do
>
> ??? shared_ptr is nowhere manual.

There is an upcoming atomic_shared_ptr, but it is not in the 
standard yet.

> My post is about particular primitive in C++ std, what could be 
> done instead or in addition to is not important.

Oh, but it is.

1. D currently does not provide what you says it does.

2. Sane C++ programmers rarely use shared_ptr for more than 
exchsnging ownership (suitable for sharing things like bitmap 
textures). There are plenty of other RC implementations for 
tracking memory. So you compare apples and oranges.





More information about the Digitalmars-d mailing list