Jump to page: 1 2
Thread overview
SmartRef: The Smart Pointer In D
Jan 13, 2017
Dsby
Jan 14, 2017
nbro
Jan 14, 2017
Swoorup Joshi
Jan 14, 2017
Dmitry Olshansky
Jan 15, 2017
Martin Nowak
Jan 14, 2017
Chris Wright
Jan 14, 2017
nbro
Jan 14, 2017
Chris Wright
Jan 14, 2017
Nordlöw
Jan 15, 2017
Dsby
Jan 15, 2017
Dsby
Jan 15, 2017
biozic
Jan 16, 2017
Dsby
Jan 16, 2017
biozic
May 30, 2018
Aedt
Jun 08, 2018
Martin Nowak
January 13, 2017
I write the ref count pointer and the scoped point in D.
it just Like cpp's shared_ptr , waek_ptr and unique_ptr .
Now, it is  Developing.
I will write more test before the frist release.
And the docs is null.
It on github: https://github.com/huntlabs/SmartRef
January 14, 2017
On Friday, 13 January 2017 at 16:50:37 UTC, Dsby wrote:
> I write the ref count pointer and the scoped point in D.
> it just Like cpp's shared_ptr , waek_ptr and unique_ptr .
> Now, it is  Developing.
> I will write more test before the frist release.
> And the docs is null.
> It on github: https://github.com/huntlabs/SmartRef

What's would be the advantages of smart pointers in D?
January 14, 2017
On Saturday, 14 January 2017 at 02:05:11 UTC, nbro 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.
>> it just Like cpp's shared_ptr , waek_ptr and unique_ptr .
>> Now, it is  Developing.
>> I will write more test before the frist release.
>> And the docs is null.
>> It on github: https://github.com/huntlabs/SmartRef
>
> What's would be the advantages of smart pointers in D?

Simple, Same Advantages you would get with C++ smart pointers.
January 14, 2017
On Sat, 14 Jan 2017 02:05:11 +0000, nbro 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. it just Like
>> cpp's shared_ptr , waek_ptr and unique_ptr .
>> Now, it is  Developing.
>> I will write more test before the frist release.
>> And the docs is null.
>> It on github: https://github.com/huntlabs/SmartRef
> 
> What's would be the advantages of smart pointers in D?

It's reference counting.

Reference counting is like garbage collection, but deamortized. This is better for real-time applications. However, it adds overhead on every assignment and every variable going out of scope.

In D, garbage collection is more expensive than it is in other languages, so the tradeoff is more attractive than it would be in other languages.
January 14, 2017
On Saturday, 14 January 2017 at 04:14:11 UTC, Chris Wright wrote:
>
> It's reference counting.
>
> Reference counting is like garbage collection, but deamortized. This is better for real-time applications. However, it adds overhead on every assignment and every variable going out of scope.
>
> In D, garbage collection is more expensive than it is in other languages, so the tradeoff is more attractive than it would be in other languages.

Garbage collection in D is more expensive just because of the poor implementation, from what I've heard. If that's the case, people who work on it should be able to improve it over time.

January 14, 2017
On Sat, 14 Jan 2017 11:52:34 +0000, nbro wrote:
> Garbage collection in D is more expensive just because of the poor implementation, from what I've heard. If that's the case, people who work on it should be able to improve it over time.

I posted about this in general.

A GC for Java, Python, Ruby, etc can locate type information and GC metadata for an allocation in O(1) time. D's can locate type information and GC metadata in O(log N) time in the worst case, even with the best possible implementation, and its design decisions make the worst case incredibly common. That is one of the common operations that a GC does, so it has a big performance impact.

D's GC must be slower because it allows pointers to arbitrary places inside an allocation, and it strongly encourages this with array slicing.
January 14, 2017
On 1/14/17 3:20 AM, Swoorup Joshi wrote:
> On Saturday, 14 January 2017 at 02:05:11 UTC, nbro 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.
>>> it just Like cpp's shared_ptr , waek_ptr and unique_ptr .
>>> Now, it is  Developing.
>>> I will write more test before the frist release.
>>> And the docs is null.
>>> It on github: https://github.com/huntlabs/SmartRef
>>
>> What's would be the advantages of smart pointers in D?
>
> Simple, Same Advantages you would get with C++ smart pointers.

Not quite true, there is at least one huge advantage - thread-locality.
That is C++ smart_ptr has to be atomic, while its D counter part may safely be non-atomic because everything is TLS be default.

Of course, there is a place for smart pointer shared across threads, but I'd personally go with message passing instead.

---
Dmitry Olshansky
January 14, 2017
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

under

https://dlang.org/phobos/std_typecons.html

?
January 15, 2017
On 01/14/2017 04:41 PM, Dmitry Olshansky wrote:
> Not quite true, there is at least one huge advantage - thread-locality. That is C++ smart_ptr has to be atomic, while its D counter part may safely be non-atomic because everything is TLS be default.

And you can add a shared postblit overload for when it's not thread local ;).
January 15, 2017
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
>
> under
>
> https://dlang.org/phobos/std_typecons.html
>
> ?
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.
« First   ‹ Prev
1 2