On Sunday, 15 January 2017 at 15:42:19 UTC, Dsby wrote:
On Saturday, 14 January 2017 at 17:35:09 UTC, Nordlöw wrote:
On Friday, 13 January 2017 at 16:50:37 UTC, Dsby wrote:
I write the ref count pointer and the scoped point in D.

How do two of these differ from

- https://dlang.org/phobos/std_typecons.html#.RefCounted
- https://dlang.org/phobos/std_typecons.html#.Unique



The RefCount not support class or inteface, and the ref count is not atomic , it not thread safe. The Unique is base of GC. It can not @nogc. And it use the 'delete' keyword , it will be deprcated(http://dlang.org/deprecate.html).

The SmartRef is Base std.experimental.allocator. You can control where the memony allocator. And the smartref.sharedref use the atomic default, you alse can not use atomic。 And have the smartref.weakref with sharedref to fix circular reference.

Sorry,In the new phobos, THe Unique is not used the 'delete' keyword.
But , it only destroy, not free the memony.

and : In https://github.com/dlang/phobos/blob/master/std/typecons.d#L147
debug(Unique) writeln("Unique destructor of ", (_p is null)? null: _p);
        if (_p !is null) destroy(_p);
        _p = null;
if the 'T' is a struct, it will not exec the Destory function. Is it a bug?

Reply via email to