LDC optimized builds causing unexpected behaviour when sharing variable between threads
Keivan Shah
keivan.shah at silverleafcaps.com
Thu Jun 2 04:49:08 UTC 2022
On Wednesday, 1 June 2022 at 15:31:40 UTC, Kagamin wrote:
> On Wednesday, 1 June 2022 at 13:35:45 UTC, Keivan Shah wrote:
>> So to me it seemed like marking the variable as `shared`
>> should have made it accessible as well as it takes care of the
>> memory ordering.
>
> No, `shared` is a low level primitive. If you want one size
> fits all concurrency, use mutex, synchronized statement or
> std.concurrency.
Hey Kagamin,
Thanks, starting to understand that a little now. Seems like that
I was relying on some incorrect assumptions and will need to make
some overall logic changes. Will look into using synchronized,
but seems like my use-case might be fine with `core.atomic` for
now since need a fast lightweight way for data sharing for a few
shared variables.
Regards and Thanks,
Keivan Shah.
More information about the digitalmars-d-ldc
mailing list