On Wednesday, 19 July 2017 at 20:59:03 UTC, Atila Neves wrote:
Not necessarily - the reference counted smart pointer doesn't have to be `shared` itself to have a `shared` payload.
Yes, but it can be done either way. It's actually what Jack is trying to do: make stdout shared and reference counted: https://issues.dlang.org/show_bug.cgi?id=15768#c7
I'm not even entirely sure what the advantage of it being `shared` would be, or even what that would really mean.
It will be thread safe and its lifetime will be automatically managed.
You've definitely made me wonder about complicated cases, but I'd argue that they'd be rare. Destructors are (bar manually calling them) run in one thread. I'm having trouble imagining a situation where two threads have references to a `shared` object/value that is going to be destroyed deterministically.
A mutex, a file, a socket, any shareable resource. Though I agree that reference counting of shared resources should be optimized by thread local counters.
