On Friday, 18 April 2014 at 10:06:35 UTC, Manu via Digitalmars-d wrote:
D pointers are thread-local by default, you need to mark things 'shared' explicitly if they are to be passed between threads. This is one of the
great advantages D has over C/C++/Obj-C.

TLS sucks, as you get extra indirections if it isn't implemented using a MMU (typically not because the extra page tables would cost too much?). Besides, when I want globals it is for database like structures so I usually want them shared anyway.

There is a reason for why Rust only uses ARC for immutable data. But that could be so useful that it might be worth it. E.g. for caches.

For efficient ARC I think you would need the equivalent of isolated threads and forbid pointers to internal data so that you can maintain ref-counting at the start of the object. Oth

Weak references is still an issue though. It takes extra effort. You either need a separate object, or you need a list of weak references to clear, or you will have to "realloc" the object (freeing the datasegment, but keeping the refcounting head, causing memory fragmentation), or some other "ugly" scheme. So you want whole program analysis to figure out for which objects you don't have to deal with weak references…

Ola.


Reply via email to