D 2.0 FAQ on `shared`

Sean Kelly via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 21 12:43:45 PDT 2014


On Tuesday, 21 October 2014 at 19:32:17 UTC, Marco Leise wrote:
>
> Do you think it would be bad if a pthread_mutex_t* was
> declared as shared or only usable when shared ?

No.  But the issue in general concerns me.  Like say my class
contains a C style FILE*.  If shared is transitive, then
fprintf() must be modified to, what, take shared(FILE*)?  Maybe
conditionally, since it won't always be shared?  I don't know
that the shared equivalent of "const" is appropriate here either,
since you'd pretty much stick it at the top of every module in
core.stdc and core.sys.


> I haven't been around in the D1 times. There was a volatile
> statement?

http://digitalmars.com/d/1.0/statement.html#VolatileStatement


> Anyways what I don't want is that the compiler
> emits memory barriers everywhere shared variables are accessed.
> When I use mutex synchronization I don't need it and when I use
> atomics, I want control over barriers.

Oh okay.  Yes, I'd be fine of all built-in operations were simply
prohibited on shared variables, so you were forced to use
core.atomic for everything.


More information about the Digitalmars-d mailing list