JvSynchronize nitpick
Tom Tromey
tromey@cygnus.com
Mon Mar 27 19:05:00 GMT 2000
>>>>> "Paul" == Paul Fisher <pnfisher@redhat.com> writes:
Paul> For JvSynchronize, why not make `synchronized' a macro (or
Paul> slightly name mangled) that expands into the current
Paul> JvSynchronize syntax?
I don't know. It was this way when I started working on it.
One problem is choosing a variable name.
Paul> So C++ code would look like:
Paul> { synchronized (OBJ); CODE; }
Paul> which is more in line with the Java syntax.
We could even play some trick using "for" and a helper object to let
us write code like this:
synchronized (foo)
{
...
}
(untested, with poor names)
class helper
{
JvSynchronize sync;
int count;
helper(obj) : sync (obj), count (0) { }
operator bool () { return count == 0; }
helper &operator++ () { ++count; return *this; }
}
#define synchronized(Object) for (helper x (Object); ! x; ++x)
That might be too magical, not to mention slow.
Tom
More information about the Java
mailing list