On 2011-10-23 20:14, Jonathan M Davis wrote:
On Sunday, October 23, 2011 14:32:34 simendsjo wrote:
What does shared for functions mean? I thought it was supposed to
automatically synchronize access, but this doesn't seem to be the case.

void f() shared {
// no synchronization
}

void f() {
    synchronized {
      // do stuff
    }
}

shared doesn't automatically synchronize anything. I believe that it makes
some guarantees about instruction ordering not being messed with by the
compiler, but I'm not sure. I'd have to go look it up in TDPL though.
Regardless, on a _function_, I don't think that shared does anything. D
probably ignores it. It tends to do that with incorrect attributes. It _might_
do something though. I don't know.

- Jonathan M Davis

Then there's the problem of TDPL and DMD being out of sync. Is shared currently implemented like that?

--
/Jacob Carlborg

Reply via email to