A few thoughts on std.allocator

via Digitalmars-d digitalmars-d at puremagic.com
Mon May 11 02:55:35 PDT 2015


On Sunday, 10 May 2015 at 09:50:00 UTC, Andrei Alexandrescu wrote:
> 3. Thread-local vs. shared objects
>
> Currently in D it's legal to allocate memory in one thread and 
> deallocate it in another. (One simple way to look at it is 
> casting to shared.) This has a large performance cost that only 
> benefits very few actual cases.
>
> It follows that we need to change the notion that you first 
> allocate memory and then brand it as shared. The "will be 
> shared" knowledge must be present during allocation, and use 
> different methods of allocation for the two cases.

In addition to an immutable/shared heap, it may also be necessary 
to transfer data from one thread to another. The shared heap is 
for data with shared ownership, while other data with (unique) 
ownership can be sent to other threads.


More information about the Digitalmars-d mailing list