ó
næDPc           @`  sþ   d  Z  d d l m Z m Z d d l m Z d e f d „  ƒ  YZ d „  Z e	 e _
 d „  Z d „  Z d	 „  Z d
 „  Z d d „ Z e ƒ  Z d „  Z d „  Z d „  Z d a e a y d d l Z Wn e k
 rÝ d Z n Xe e	 ƒ d d d d g Z d S(   sT   
A module to provide some very basic threading primitives, such as
synchronization.
i    (   t   divisiont   absolute_import(   t   wrapst	   DummyLockc           B`  s   e  Z d  Z d „  Z RS(   sF   
    Hack to allow locks to be unpickled on an unthreaded system.
    c         C`  s
   t  d f S(   N(    (   t   unpickle_lock(   t   self(    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt
   __reduce__   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyR      s   c           C`  s   t  d  k	 r t ƒ  St ƒ  Sd  S(   N(   t   threadingmodulet   Nonet   XLockR   (    (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyR      s    c         C`  sY   d |  j  k rH t j ƒ  d |  j  k r; t ƒ  |  j  d <n  t j ƒ  n  |  j j ƒ  d  S(   Nt   _threadable_lock(   t   __dict__t   _synchLockCreatort   acquireR   t   releaseR   (   R   (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt	   _synchPre!   s    
c         C`  s   |  j  j ƒ  d  S(   N(   R   R   (   R   (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt
   _synchPost+   s    c         `  s   t  ˆ  ƒ ‡  f d †  ƒ } | S(   Nc         `  s0   t  |  ƒ z ˆ  |  | | Ž SWd  t |  ƒ Xd  S(   N(   R   R   (   R   t   argst   kwargs(   t   function(    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt   sync1   s    
(   R   (   t   klassR   R   (    (   R   sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt   _sync0   s    c          G`  s^   t  d k	 rZ xK |  D]@ } x7 | j D], } t | | j | ƒ } t | | | ƒ q# Wq Wn  d S(   s&  
    Make all methods listed in each class' synchronized attribute synchronized.

    The synchronized attribute should be a list of strings, consisting of the
    names of methods that must be synchronized. If we are running in threaded
    mode these methods will be wrapped with a lock.
    N(   R
   R   t   synchronizedR   R   t   setattr(   t   klassesR   t
   methodNameR   (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt   synchronize<   s
    i   c         C`  sq   |  rX t  sm t d k	 rF t a  d t j t f d „  ƒ  Ya t ƒ  a qU t d ƒ ‚ qm n t  rm t d ƒ ‚ n  d S(   sb   Initialize threading.

    Don't bother calling this.  If it needs to happen, it will happen.
    R   c           B`  s   e  Z d  „  Z RS(   c         S`  s
   t  d f S(   N(    (   R   (   R   (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyR   Y   s    (   R   R   R   (    (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyR   X   s   s:   Cannot initialize threading, platform lacks thread supports   Cannot uninitialize threadsN(	   t   threadedR
   R   t   Truet   _RLockt   objectR   R   t   RuntimeError(   t   with_threads(    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt   initL   s    c           C`  s   t  d  k r t St  j ƒ  j S(   N(   R
   R   t   _dummyIDt   currentThreadt   ident(    (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt   getThreadIDh   s    c           C`  s   t  t ƒ  k S(   sH   Are we in the thread responsable for I/O requests (the event loop)?
    (   t   ioThreadR)   (    (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt   isInIOThreado   s    c           C`  s   t  ƒ  a d S(   s=   Mark the current thread as responsable for I/O requests.
    N(   R)   R*   (    (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt   registerAsIOThreadv   s    NR+   R,   R)   R   (   R	   t
   __future__R    R   t	   functoolsR   R"   R   R   R    t   __safe_for_unpickling__R   R   R   R   R%   R&   R)   R+   R,   R   R*   t   FalseR   t	   threadingR
   t   ImportErrort   __all__(    (    (    sK   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/threadable.pyt   <module>   s,   
			
							

