This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]