This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: JvSynchronize nitpick
Tom Tromey <tromey@cygnus.com> writes:
> That might be too magical, not to mention slow.
I'm rather fond of that magic. How about something a bit simpler?
class JvSynchronizeHelper
{
JvSynchronize sync;
public:
bool done;
JvSynchronizeHelper (const jobject &obj) : sync (obj), done (false) { }
};
#define synchronized(OBJECT) \
for (JvSynchronizeHelper JvX (OBJECT); !JvX.done; JvX.done = true)
Of course, this could wreak havoc if a `break' or a `continue' were to
occur inside of a synchronized block contained within an iterative
construct. For that situation, one could always fall back to using
JvSynchronize, but would that be too confusing?