implicit conversions to/from shared

Alex Parrill via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 10 16:52:32 PDT 2016


On Sunday, 10 July 2016 at 13:02:17 UTC, ag0aep6g wrote:
> While messing with atomicLoad [1], I noticed that dmd lets me 
> implicitly convert values to/from shared without restrictions. 
> It's in the spec [2]. This seems bad to me.
>
> [...]

Atomic loading and storing, from what I understand, is usually 
limited to about a word on most architectures. I don't think it 
would be good to implicitly define assignment and referencing as 
atomic operations, since it would be limited. IMO concurrent 
access is better off being explicit anyway.

I don't think there is an issue with converting unshared 
reference types to shared (ex. ref T -> ref shared(T) or T* -> 
shared(T)*); worst you get is some extra synchronization.


More information about the Digitalmars-d mailing list