File: //proc/2/task/2/root/usr/lib/python2.4/Demo/metaclasses/Synch.pyo
mò
‚=5Dc @ sÄ d Z d k Z d f d „ ƒ YZ d „ Z d k l Z l Z l Z d e f d „ ƒ YZ d e f d „ ƒ YZ d
e f d „ ƒ YZ
e
d f h ƒ Z d
„ Z e
d j o e ƒ e ƒ n d S( s` Synchronization metaclass.
This metaclass makes it possible to declare synchronized methods.
Nt Lockc B s, t Z d Z d „ Z d d „ Z d „ Z RS( s Reentrant lock.
This is a mutex-like object which can be acquired by the same
thread more than once. It keeps a reference count of the number
of times it has been acquired by the same thread. Each acquire()
call must be matched by a release() call and only the last
release() call actually releases the lock for acquisition by
another thread.
The implementation uses two locks internally:
__mutex is a short term lock used to protect the instance variables
__wait is the lock for which other threads wait
A thread intending to acquire both locks should acquire __wait
first.
The implementation uses two other instance variables, protected by
locking __mutex:
__tid is the thread ID of the thread that currently has the lock
__count is the number of times the current thread has acquired it
When the lock is released, __tid is None and __count is zero.
c C s4 t i ƒ | _ t i ƒ | _ d | _ d | _ d S( s0 Constructor. Initialize all instance variables.i N( t threadt
allocate_lockt selft _Lock__mutext _Lock__waitt Nonet
_Lock__tidt _Lock__count( R ( ( t, /usr/lib/python2.4/Demo/metaclasses/Synch.pyt __init__* s
i c C s¼ | i i ƒ z2 | i t i ƒ j o | i d | _ d Sn Wd | i i ƒ X| i i | ƒ } | o | o d Sn z- | i i ƒ t i ƒ | _ d | _ d SWd | i i ƒ Xd S( s} Acquire the lock.
If the optional flag argument is false, returns immediately
when it cannot acquire the __wait lock without blocking (it
may still block for a little while in order to acquire the
__mutex lock).
The return value is only relevant when the flag argument is
false; it is 1 if the lock is acquired, 0 if not.
i Ni ( R R t acquireR R t get_identR t releaseR t flagt locked( R R R ( ( R R 1 s(
c C s` | i i ƒ z>