Dare I ... another volatile discussion ?
Jens Bauer via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 9 03:29:43 PDT 2015
On Thursday, 7 May 2015 at 21:42:08 UTC, Iain Buclaw wrote:
> On 7 May 2015 at 23:39, Iain Buclaw <ibuclaw at gdcproject.org>
> wrote:
>> When used properly though, it's properties make it a prime
>> candidate
>> for the foundation of libraries/programs that centre around
>> the use of
>> atomics. However, shared is not to be confused with a
>> thread-safe
>> atomic type. Thread-safety is left to the end-user on such
>> matters of
>> access.
>>
>
> That last sentence should also include a mention of memory
> ordering
> too being left to the end-user.
Thank you for explaining this; it does make sense. :)
-So 'shared' is not to be confused with 'atomic'; its behaviour
seems closer to C's "extern", do I understand this correctly ?
One of the reasons I asked the question, is because no doubt D
will need to write to hardware on any kind of platform, and I'd
like it to be the same on both microcontrollers and a Personal
Computer (not limited to a specific kind of processor).
Another thing, slightly related, is 'atomic'. C's implementation
allows you to have a function, which reads/modifies/writes a
value atomically. This is all implemented 'outside' the C
language.
Would it make sense to mark a variable 'atomic', or would it be
rather crazy, because if it's extern(C) anyway, C wouldn't access
it atomically ?
More information about the Digitalmars-d
mailing list