On Wednesday, 9 October 2013 at 14:17:44 UTC, Sean Kelly wrote:
On Oct 9, 2013, at 4:30 AM, Jacob Carlborg <d...@me.com> wrote:
On 2013-10-09 05:31, Walter Bright wrote:
Making this work is fraught with difficulty. It is normal
behavior in D
to create local data with new(), build a data structure, and
then cast
it to shared so it can be transferred to another thread. This
will fail
miserably if the data is allocated on a thread local heap.
I agree with Andrei here. Alternatively perhaps the runtime
can move the data to a global pool if it's casted to shared.
Generally not, since even D's precise GC is partially
conservative. It's also way more expensive than any cast
should be. For better or worse, I think being able to cast data
to shared means that we can't have thread-local pools. Unless a
new attribute were introduced like "local" that couldn't ever
be cast to shared, and that sounds like a disaster.
That isn't accurant. Allocator like tcmalloc use thread local
info to allocate shared chunk of memory. What does matter is that
the block is tagged as shared as far as the GC is oncerned.
Casting qualifier is a NOOP at machine level, so that won't be
any slower.