On Thursday, 8 May 2014 at 17:49:01 UTC, Steven Schveighoffer wrote:
To what end? What are you trying to save?
I'm trying to reimplement std.variant in a nice OOP way, that supports CTFE, zero-size and a minimal amount of void*-casts. For that i'm using my VariantPayload(T) class, which i want to be as small as possible, as this is supposed to be an utility class which you never know how will be used.


It would not be derived from Object, which has the field. In other words, this would crash:

synchronized(cast(Object)obj) { ... }
Wouldn't cast(Object) return null here, so that synchronized will throw or assert or smth? I see no reason for a crash.

Perhaps you meant unshared classes? No, they don't, but a monitor is only allocated on demand, so you don't have to worry about it.
Errm.. I'm not sure i understand the subject correctly, but according to Alexandrescu's book, a class declared as shared does not require synchronized() over it. I mean, it manages it's synchronization inside itself, and it's user just has to trust it. And if so, why ever synchronizing() on it?

Reply via email to