An important pull request: accessing shared affix for immutable data
ZombineDev via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 13 10:22:17 PST 2016
On Saturday, 13 February 2016 at 18:16:43 UTC, Timon Gehr wrote:
> On 13.02.2016 18:42, Andrei Alexandrescu wrote:
>> On 02/13/2016 11:55 AM, Timon Gehr wrote:
>>> If you alias the same data as both shared and unshared, the
>>> shared
>>> version can be sent to another thread which will then modify
>>> it,
>>> violating the guarantees on the unshared reference.
>>
>> Oh, I understand. So you're thinking of someone taking the
>> address of
>> allocator.prefix(block) and sharing it across threads? --
>> Andrei
>
> Not necessarily. shared is transitive and prefix/suffix are
> arbitrary types which might contain mutable indirections.
>
> I don't really see why this part of the allocator interface
> should even be typed.
I think it would be a lot simpler if we can consider allocations
from unshared allocator objects to be unshareable. This rules out
GCAllocator and Mallocator, but thread-local allocators can offer
better performance anyway.
More information about the Digitalmars-d
mailing list