I like that. One could also give them an identifier so that they can be locked outside the object, and used for objects overloading `[]. (Say, "`mutex_lock <variable>".)
class A { syncronized mixed foo; }
A a=A(); syncronized(a->foo) { ... }
But now it gets tricky to implement. :) But not that tricky, since syncronized() already must take an lvalue.
/ Mirar
Previous text:
2003-02-06 04:22: Subject: synchronized
That the mutex is allocated in the same object that contains the variable(s) it protects. E.g.
synchronized mapping foo;
would allocation-wise be similar to
Thread.Mutex foo_mutex; mapping foo;
Note that it's the variable foo itself that's the principal point of the mutex protection, not its value. One advantage with that is that it's possible to protect simple types like integers and strings where it would be meaningless to associate a mutex with the value.
/ Martin Stjernholm, Roxen IS