Ë
    ojí"  ã                   ó2  — d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 	  eed«      Z eed«      Z eed	«      Z eed
«      Z eed«      Z ee«       G d„ dej(                  ej*                  «      «       Zd„ ZddgZy# e$ rZ ee«      ‚dZ[ww xY w)zõ
An epoll() based implementation of the twisted main loop.

To install the event loop (and you should do this before any connections,
listeners or connectors are added)::

    from twisted.internet import epollreactor
    epollreactor.install()
é    N)Úimplementer)Ú	posixbase)ÚIReactorFDSet)ÚlogÚepollÚEPOLLHUPÚEPOLLERRÚEPOLLINÚEPOLLOUTc                   óh   — e Zd ZdZeez  ZeZe	Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ ZeZy)ÚEPollReactora‡  
    A reactor that uses epoll(7).

    @ivar _poller: A C{epoll} which will be used to check for I/O
        readiness.

    @ivar _selectables: A dictionary mapping integer file descriptors to
        instances of C{FileDescriptor} which have been registered with the
        reactor.  All C{FileDescriptors} which are currently receiving read or
        write readiness notifications will be present as values in this
        dictionary.

    @ivar _reads: A set containing integer file descriptors.  Values in this
        set will be registered with C{_poller} for read readiness notifications
        which will be dispatched to the corresponding C{FileDescriptor}
        instances in C{_selectables}.

    @ivar _writes: A set containing integer file descriptors.  Values in this
        set will be registered with C{_poller} for write readiness
        notifications which will be dispatched to the corresponding
        C{FileDescriptor} instances in C{_selectables}.

    @ivar _continuousPolling: A L{_ContinuousPolling} instance, used to handle
        file descriptors (e.g. filesystem files) that are not supported by
        C{epoll(7)}.
    c                 óà   — t        d«      | _        t        «       | _        t        «       | _        i | _        t        j                  | «      | _        t        j                  j                  | «       y)zm
        Initialize epoll object, file descriptor tracking dictionaries, and the
        base class.
        i   N)r   Ú_pollerÚsetÚ_readsÚ_writesÚ_selectablesr   Ú_ContinuousPollingÚ_continuousPollingÚPosixReactorBaseÚ__init__)Úselfs    ú?/usr/lib/python3/dist-packages/twisted/internet/epollreactor.pyr   zEPollReactor.__init__G   sP   € ô ˜T“{ˆŒÜ“eˆŒÜ“uˆŒØˆÔÜ"+×">Ñ">¸tÓ"DˆÔÜ×"Ñ"×+Ñ+¨DÕ1ó    c                 óâ   — |j                  «       }||vr[|}||v r"||z  }| j                  j                  ||«       n| j                  j                  ||«       |j	                  |«       |||<   yy)zÖ
        Private method for adding a descriptor from the event loop.

        It takes care of adding it if  new or modifying it if already added
        for another state (read -> read/write for example).
        N)Úfilenor   ÚmodifyÚregisterÚadd)	r   ÚxerÚprimaryÚotherÚselectablesÚeventÚ	antieventÚfdÚflagss	            r   Ú_addzEPollReactor._addV   sr   € ð �Z‰Z‹\ˆØ�WÑØˆEð �U‰{Ø˜Ñ"�Ø—‘×#Ñ# B¨Õ.à—‘×%Ñ% b¨%Ô0ð �K‰K˜ŒOØ!ˆK˜ŠOð! r   c                 ó  — 	 | j                  || j                  | j                  | j                  t        t
        «       y# t        $ rD}|j                  t        j                  k(  r| j                  j                  |«       n‚ Y d}~yd}~ww xY w)zR
        Add a FileDescriptor for notification of data available to read.
        N)r(   r   r   r   r
   r   ÚOSErrorÚerrnoÚEPERMr   Ú	addReader)r   ÚreaderÚes      r   r-   zEPollReactor.addReaderp   sn   € ð	Ø�I‰IØ˜Ÿ™ T§\¡\°4×3DÑ3DÄgÌxõøô ò 	Ø�w‰wœ%Ÿ+™+Ò%ð ×'Ñ'×1Ñ1°&Õ9àô :ûð	úó   ‚<? ¿	BÁ:BÂBc                 ó  — 	 | j                  || j                  | j                  | j                  t        t
        «       y# t        $ rD}|j                  t        j                  k(  r| j                  j                  |«       n‚ Y d}~yd}~ww xY w)zS
        Add a FileDescriptor for notification of data available to write.
        N)r(   r   r   r   r   r
   r*   r+   r,   r   Ú	addWriter)r   Úwriterr/   s      r   r2   zEPollReactor.addWriter�   so   € ð	Ø�I‰IØ˜Ÿ™ d§k¡k°4×3DÑ3DÄhÔPWõøô ò 	Ø�w‰wœ%Ÿ+™+Ò%ð ×'Ñ'×1Ñ1°&Õ9àô :ûð	úr0   c                 ó  — |j                  «       }|dk(  r|j                  «       D ]  \  }}||u sŒ n y||v rS||v r|}	| j                  j                  ||	«       n||= | j                  j	                  |«       |j                  |«       yy)z·
        Private method for removing a descriptor from the event loop.

        It does the inverse job of _add, and also add a check in case of the fd
        has gone away.
        éÿÿÿÿN)r   Úitemsr   r   Ú
unregisterÚremove)
r   r    r!   r"   r#   r$   r%   r&   Úfdesr'   s
             r   Ú_removezEPollReactor._remove’   s’   € ð �Z‰Z‹\ˆØ�Š8Ø'×-Ñ-Ó/ò ‘��DØ˜$’;Ùðð Ø�‰=Ø�U‰{Ø!�à—‘×#Ñ# B¨Õ.à �Oà—‘×'Ñ'¨Ô+Ø�N‰N˜2Õð r   c                 óê   — | j                   j                  |«      r| j                   j                  |«       y| j                  || j                  | j
                  | j                  t        t        «       y)zQ
        Remove a Selectable for notification of data available to read.
        N)	r   Ú	isReadingÚremoveReaderr:   r   r   r   r
   r   )r   r.   s     r   r=   zEPollReactor.removeReader«   sV   € ð ×"Ñ"×,Ñ,¨VÔ4Ø×#Ñ#×0Ñ0°Ô8ØØ�‰Ø�D—K‘K §¡¨t×/@Ñ/@Ä'Ì8õ	
r   c                 óê   — | j                   j                  |«      r| j                   j                  |«       y| j                  || j                  | j
                  | j                  t        t        «       y)zR
        Remove a Selectable for notification of data available to write.
        N)	r   Ú	isWritingÚremoveWriterr:   r   r   r   r   r
   )r   r3   s     r   r@   zEPollReactor.removeWriter¶   sV   € ð ×"Ñ"×,Ñ,¨VÔ4Ø×#Ñ#×0Ñ0°Ô8ØØ�‰Ø�D—L‘L $§+¡+¨t×/@Ñ/@Ä(ÌGõ	
r   c                 ó  — | j                  | j                  D �cg c]  }| j                  |   ‘Œ c}| j                  D �cg c]  }| j                  |   ‘Œ c}«      | j                  j                  «       z   S c c}w c c}w )zD
        Remove all selectables, and return a list of them.
        )Ú
_removeAllr   r   r   r   Ú	removeAll©r   r&   s     r   rC   zEPollReactor.removeAllÁ   sn   € ð
 �O‰OØ15·±Ö=¨2�×"Ñ" 2Ó&Ò=Ø15·±Ö>¨2�×"Ñ" 2Ó&Ò>óð ×%Ñ%×/Ñ/Ó1ñ	2ð	
ùâ=ùÚ>s   šA8Á A=
c                 ó�   — | j                   D �cg c]  }| j                  |   ‘Œ c}| j                  j                  «       z   S c c}w ©N)r   r   r   Ú
getReadersrD   s     r   rG   zEPollReactor.getReadersÍ   sE   € à,0¯K©Kö
Ø&(ˆD×Ñ˜bÓ!ò
à×#Ñ#×.Ñ.Ó0ñ1ð 	1ùò 
ó   �Ac                 ó�   — | j                   D �cg c]  }| j                  |   ‘Œ c}| j                  j                  «       z   S c c}w rF   )r   r   r   Ú
getWritersrD   s     r   rJ   zEPollReactor.getWritersÒ   sE   € à,0¯L©Lö
Ø&(ˆD×Ñ˜bÓ!ò
à×#Ñ#×.Ñ.Ó0ñ1ð 	1ùò 
rH   c                 óp  — |€d}	 | j                   j                  |t        | j                  «      «      }| j                  }|D ].  \  }}	 | j                  |   }t        j                  |||||«       Œ0 y# t        $ r(}|j
                  t
        j                  k(  rY d}~y‚ d}~ww xY w# t        $ r Y Œqw xY w)z1
        Poll the poller for new events.
        Nr5   )r   ÚpollÚlenr   r*   r+   ÚEINTRÚ_doReadOrWriter   ÚcallWithLoggerÚKeyError)r   ÚtimeoutÚlÚerrÚ_drdwr&   r$   Ú
selectables           r   ÚdoPollzEPollReactor.doPoll×   sÃ   € ð ˆ?ØˆGð	ð
 —‘×!Ñ! '¬3¨t×/@Ñ/@Ó+AÓBˆAð ×#Ñ#ˆØò 	M‰IˆB�ðMØ!×.Ñ.¨rÑ2�
ô ×"Ñ" :¨u°jÀ"ÀeÕLñ	Møô ò 	Ø�y‰yœEŸK™KÒ'Üð
 ûð	ûô ò Ùðús/   †/A5 Á
B)Á5	B&Á>B!Â B!Â!B&Â)	B5Â4B5N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   Ú_POLL_DISCONNECTEDr
   Ú_POLL_INr   Ú	_POLL_OUTr   r(   r-   r2   r:   r=   r@   rC   rG   rJ   rW   ÚdoIteration© r   r   r   r   %   s]   „ ñð8 " HÑ,ÐØ€HØ€Iò2ò"ò4ò"ò"ò2	
ò	
ò

ò1ò
1ò
Mð> �Kr   r   c                  ó4   — t        «       } ddlm}  || «       y)z&
    Install the epoll() reactor.
    r   )ÚinstallReactorN)r   Útwisted.internet.mainrb   )Úprb   s     r   Úinstallre   ù   s   € ô 	‹€AÝ4á�1Õr   re   )r[   r+   ÚselectÚzope.interfacer   Útwisted.internetr   Útwisted.internet.interfacesr   Útwisted.pythonr   Úgetattrr   r   r	   r
   r   ÚAttributeErrorr/   ÚImportErrorr   Ú_PollLikeMixinr   re   Ú__all__r`   r   r   ú<module>rp      sÁ   ðñó Û å &å &Ý 5Ý ðñ
 �F˜GÓ$€EÙ�v˜zÓ*€HÙ�v˜zÓ*€HÙ�f˜iÓ(€GÙ�v˜zÓ*€Hñ
 ˆ]ÓôP�9×-Ñ-¨y×/GÑ/Gó Pó ðPòfð ˜9Ð
%�øðE ò Ù
�a‹.Ðûðús   ¤-B ÂBÂ	BÂB