synchronized (this[.classinfo]) in druntime and phobos
Jonathan M Davis
jmdavisProg at gmx.com
Mon May 28 16:20:33 PDT 2012
On Tuesday, May 29, 2012 01:11:49 Alex Rønne Petersen wrote:
> I have no idea how synchronized classes work; they are not a documented
> feature of the language. We have synchronized functions which
> synchronize on the this reference. Perhaps synchronized classes just
> make all functions in a class do this.
Per TDPL, having individually synchronized functions is illegal. Either _all_
of the functions in a class are synchronized or _none_ of them are. Putting
synchronized on a function should actually be illegal. It belongs only on
classes or in synchronized blocks, never on functions.
Now, unfortuntately, I don't believe that the compiler enforces any of that
right now, so you end up synchronizing indivdual functions rather than whole
classes, but the synchronized functions themselves should function the same.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list