Current Path : /usr/lib/python2.7/dist-packages/twisted/internet/ |
Current File : //usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyc |
Mc @ s d Z d d l Z d d l m Z d d l m Z d d l m Z m Z d d l m Z d e j e j f d YZ d Z d d g Z d S( s 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() iN( t implements( t IReactorFDSet( t logt _epoll( t posixbaset EPollReactorc B s e Z d Z e e e j e j BZ e j Z e j 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 RS( sX A reactor that uses epoll(4). @ivar _poller: A L{poll} which will be used to check for I/O readiness. @ivar _selectables: A dictionary mapping integer file descriptors to instances of L{FileDescriptor} which have been registered with the reactor. All L{FileDescriptors} which are currently receiving read or write readiness notifications will be present as values in this dictionary. @ivar _reads: A dictionary mapping integer file descriptors to arbitrary values (this is essentially a set). Keys in this dictionary will be registered with C{_poller} for read readiness notifications which will be dispatched to the corresponding L{FileDescriptor} instances in C{_selectables}. @ivar _writes: A dictionary mapping integer file descriptors to arbitrary values (this is essentially a set). Keys in this dictionary will be registered with C{_poller} for write readiness notifications which will be dispatched to the corresponding L{FileDescriptor} instances in C{_selectables}. c C sA t j d | _ i | _ i | _ i | _ t j j | d S( sm Initialize epoll object, file descriptor tracking dictionaries, and the base class. i N( R t epollt _pollert _readst _writest _selectablesR t PosixReactorBaset __init__( t self( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyR 8 s c C sz | j } | | k rv t j } | } | | k rI | | O} t j } n | j j | | | d | | <| | | <n d S( s 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). i N( t filenoR t CTL_ADDt CTL_MODR t _control( R t xert primaryt othert selectablest eventt antieventt fdt cmdt flags( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt _addF s c C s/ | j | | j | j | j t j t j d S( sR Add a FileDescriptor for notification of data available to read. N( R R R R R t INt OUT( R t reader( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt addReadera s c C s/ | j | | j | j | j t j t j d S( sS Add a FileDescriptor for notification of data available to write. N( R R R R R R R ( R t writer( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt addWriterh s c C s | j } | d k rL x1 | j D] \ } } | | k r% Pq% q% Wd Sn | | k r t j } | } | | k r | } t j } n | | =| | =| j j | | | n d S( s 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. iN( R t itemsR t CTL_DELR R R ( R R R R R R R R t fdesR R ( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt _removeo s c C s/ | j | | j | j | j t j t j d S( sQ Remove a Selectable for notification of data available to read. N( R% R R R R R R ( R R ( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt removeReader s c C s/ | j | | j | j | j t j t j d S( sR Remove a Selectable for notification of data available to write. N( R% R R R R R R ( R R ( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt removeWriter s c C sJ | j g | j D] } | j | ^ q g | j D] } | j | ^ q0 S( sD Remove all selectables, and return a list of them. ( t _removeAllR R R ( R R ( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt removeAll s c C s! g | j D] } | j | ^ q S( N( R R ( R R ( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt getReaders s c C s! g | j D] } | j | ^ q S( N( R R ( R R ( ( sA /usr/lib/python2.7/dist-packages/twisted/internet/epollreactor.pyt getWriters s c C s | d k r d } n t | d } y"