shared - i need it to be useful
Steven Schveighoffer
schveiguy at gmail.com
Wed Oct 17 15:53:08 UTC 2018
On 10/17/18 10:33 AM, Nicholas Wilson wrote:
> On Wednesday, 17 October 2018 at 14:26:43 UTC, Timon Gehr wrote:
>> On 17.10.2018 16:14, Nicholas Wilson wrote:
>>>
>>> I was thinking that mutable -> shared const as apposed to mutable ->
>>> shared would get around the issues that Timon posted.
>>
>> Unfortunately not. For example, the thread with the mutable reference
>> is not obliged to actually make the changes that are performed on that
>> reference visible to other threads.
>
> Yes, but that is covered by not being able to read non-atomically from a
> shared reference.
All sides must participate in synchronization for it to make sense. The
mutable side has no obligation to use atomics. It can use ++data, and
race conditions will happen.
-Steve
More information about the Digitalmars-d
mailing list