%PDF- %PDF-
Direktori : /proc/thread-self/root/lib64/python2.7/Demo/metaclasses/ |
Current File : //proc/thread-self/root/lib64/python2.7/Demo/metaclasses/Synch.pyo |
� ��^c @ s� d Z d d l Z d d d � � YZ d � Z d d l m Z m Z m Z d e f d � � YZ d e f d � � YZ d e f d � � YZ e d d i � Z d � Z e d k r� e � e � n d S( s` Synchronization metaclass. This metaclass makes it possible to declare synchronized methods. i����Nt Lockc B s, e 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 j � | _ t j � | _ d | _ d | _ d S( s0 Constructor. Initialize all instance variables.i N( t threadt allocate_lockt _Lock__mutext _Lock__waitt Nonet _Lock__tidt _Lock__count( t self( ( s. /usr/lib64/python2.7/Demo/metaclasses/Synch.pyt __init__* s i c C s� | j j � z- | j t j � k r9 | j d | _ d SWd | j j � X| j j | � } | ro | ro d Sz- | j j � t j � | _ d | _ d SWd | j j � 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 t acquireR R t get_identR t releaseR ( R t flagt locked( ( s. /usr/lib64/python2.7/Demo/metaclasses/Synch.pyR 1 s c C s^ | j j � z<