File: //opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyo
�
^��Jc           @   sv  d  Z  d d l Z d d l Z d d l Z y d d l Z Wn e k
 rY d d l Z n Xy e j �  e	 Z
 Wn7 y d d l Z e Z
 Wq� e k
 r� e	 Z
 q� Xn Xd d l
 m Z d d l m Z d d d d d	 g Z d e f d
 �  �  YZ e j �  Z d �  Z d �  Z d
 �  Z d e f d �  �  YZ d e f d �  �  YZ d e f d �  �  YZ d e f d �  �  YZ d S(   s�   Synchronization functions.
File- and mutex-based mutual exclusion synchronizers are provided,
as well as a name-based mutex which locks within an application
based on a string name.
i����N(   t   util(   t	   LockErrort   file_synchronizert   mutex_synchronizert   null_synchronizert   NameLockt
   _threadingc           B   sT   e  Z d  Z e j �  Z d e f d �  �  YZ d e	 d � Z
 e d � Z d �  Z
 RS(   s�   a proxy for an RLock object that is stored in a name based
    registry.  
    
    Multiple threads can get a reference to the same RLock based on the
    name alone, and synchronize operations related to that name.
    t   NLContainerc           B   s   e  Z d  �  Z d �  Z RS(   c         C   s+   | r t  j �  |  _ n t  j �  |  _ d  S(   N(   R   t   RLockt   lockt   Lock(   t   selft	   reentrant(    (    sG   /opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyt   __init__/   s    c         C   s   |  j  S(   N(   R	   (   R   (    (    sG   /opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyt   __call__4   s    (   t   __name__t
   __module__R
   R   (    (    (    sG   /opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR   .   s   	c         C   sC   | d  k r! t j | � |  _ n t j j | t j | � |  _ d  S(   N(   t   NoneR   R   t   _lockt   lockst   get(   R   t
   identifierR   (    (    sG   /opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR
   7   s    c         C   s   |  j  �  j | � S(   N(   R   t   acquire(   R   t   wait(    (    sG   /opt/alt/python27/lib/python2.7/site-packages/beaker/synchronization.pyR   >