ó
[³XMc           @   sñ   d  Z  d d l m Z d e f d „  ƒ  YZ d „  Z e e _ 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 d d l Z Wn e k
 rÐ d Z d Z n Xe e ƒ d d d d g Z d S(   s  
A module that will allow your program to be multi-threaded,
micro-threaded, and single-threaded.  Currently microthreads are
unimplemented.  The idea is to abstract away some commonly used
functionality so that I don't have to special-case it in all programs.
iÿÿÿÿ(   t   hookt	   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(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyt
   __reduce__   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyR      s   c           C   s   t  d  k	 r t ƒ  St ƒ  Sd  S(   N(   t   threadingmodulet   Nonet   XLockR   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyR      s    c         O   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   t   at   b(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyt	   _synchPre    s    
c         O   s   |  j  j ƒ  d  S(   N(   R   R   (   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyt
   _synchPost(   s    c          G   s^   t  d k	 rZ xK |  D]@ } x7 | j D], } t j | | t ƒ 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(   t   threadmoduleR	   t   synchronizedR    t   addPreR   t   addPostR   (   t   klassest   klasst
   methodName(    (    s=   /usr/lib/python2.7/dist-packages/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   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyR   E   s    (   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyR
   D   s   s:   Cannot initialize threading, platform lacks thread supports   Cannot uninitialize threadsN(
   t   threadedR   R	   t   TrueR   t   _RLockt   objectR
   R   t   RuntimeError(   t   with_threads(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyt   init8   s    c           C   s   t  d  k r t St  j ƒ  S(   N(   R   R	   t   _dummyIDt	   get_ident(    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyt   getThreadIDR   s    c           C   s   t  t ƒ  k S(   sH   Are we in the thread responsable for I/O requests (the event loop)?
    (   t   ioThreadR%   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyt   isInIOThreadX   s    c           C   s   t  ƒ  a d S(   s=   Mark the current thread as responsable for I/O requests.
    N(   R%   R&   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyt   registerAsIOThread_   s    NR'   R(   R%   R
   (   R   t   twisted.pythonR    R   R   R   R   t   __safe_for_unpickling__R   R   R   R"   R#   R%   R'   R(   R	   R&   t   FalseR   t   threadR   t	   threadingR   t   ImportErrort   __all__(    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/threadable.pyt   <module>   s,   									

