A few thoughts on std.allocator
Panke via Digitalmars-d
digitalmars-d at puremagic.com
Sun May 10 04:05:47 PDT 2015
On Sunday, 10 May 2015 at 10:51:54 UTC, Michel Fortin wrote:
> 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.
If immutable does not pull its weight in other ways, it's just
not worth it.
More information about the Digitalmars-d