That looks nicer then my solution. If you can get that to work, I'm all for it. It also has the benefit that it will syncrhonize on the variable, not the value.
/ Mirar
Previous text:
2003-02-05 18:29: Subject: synchronized
Even in that case the declaration for the variable ought have some sort of flag that it has a mutex, i.e. that the mutex still is declared in one way or the other. E.g:
synchronized mapping foo; mapping bar; ... void f() { synchronized (foo) {...} // Ok. synchronized (bar) {...} // Error: bar doesn't have a mutex. }
There are two reasons for this requirement: As I've said earlier it avoids silently getting mutexes on the wrong things when one happens to mixup variables. Another reason is that it allows more efficient implementation since the space for a mutex can be allocated at compile time. (Note that the proposed solution with a weak mapping is prone to cause gc overhead since the locked things can't be refcount garbed.)
/ Martin Stjernholm, Roxen IS