Module synchronized
source code
I provi to de mechanisms similar to the ``synchronized`` keyword in
Java.
The idea is to associate a reentrant lock to each object, with the
possibility for a section of code to claim that lock. Functions
`enter_cs` and `exit_cs` can be used for synchronizing any section of
code on any object, while the `synchronized` decorator can be used to
synchronize a whole method on its ``self`` parameter.
|
enter_cs(obj)
Enter a critical section on `obj`. |
source code
|
|
|
exit_cs(obj)
Exit a critical section on `obj`. |
source code
|
|
|
synchronized(f)
A decorator for synchronized methods (alla Java). |
source code
|
|