A few thoughts on std.allocator
Michel Fortin via Digitalmars-d
digitalmars-d at puremagic.com
Sun May 10 03:51:54 PDT 2015
On 2015-05-10 09:50:00 +0000, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> 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.
Shared is implicit in the case of immutable. Think carefully: if you
implement this and it has any efficiency benefit for non-shared
allocations, const-allocated objects and arrays will become more
performant than immutable-allocated ones. People will thus have an
incentive to stay away from immutable.
--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca
More information about the Digitalmars-d
mailing list