�
Ϫ�fB* � �r � d Z ddlZddlZddlmZmZmZmZ ddlm Z m
Z
ddlmZm
Z
ddlmZmZ eed� Z eed� Z eed � Z eed
� Z eed� Z G d� d
e� Z ej6 ee� ee
e� G d� de
j8 � � Zd� ZddgZy# e$ r
Z ee� �dZ[ww xY w)am
A kqueue()/kevent() based implementation of the Twisted main loop.
To use this reactor, start your application specifying the kqueue reactor::
twistd --reactor kqueue ...
To install the event loop from code (and you should do this before any
connections, listeners or connectors are added)::
from twisted.internet import kqreactor
kqreactor.install()
� N)� Attribute� Interface�declarations�implementer)�main� posixbase)�IReactorDaemonize�
IReactorFDSet)�failure�log� KQ_EV_ADD�KQ_EV_DELETE� KQ_EV_EOF�KQ_FILTER_READ�KQ_FILTER_WRITEc �0 � e Zd ZdZ ed� Z ed� Zy)�_IKQueuez2
An interface for KQueue implementations.
zAn implementation of kqueue(2).zAn implementation of kevent(2).N)�__name__�
__module__�__qualname__�__doc__r �kqueue�kevent� � �</usr/lib/python3/dist-packages/twisted/internet/kqreactor.pyr r * s � �� �8�
9�F�
�8�
9�Fr r c �f � e Zd ZdZefd�Zd� Zd� Zd� Zd� Z d� Z
d� Zd � Zd
� Z
d� Zd� Zd
� Zd� ZeZy)�
KQueueReactoram
A reactor that uses kqueue(2)/kevent(2) and relies on Python 2.6 or higher
which has built in support for kqueue in the select module.
@ivar _kq: A C{kqueue} which will be used to check for I/O readiness.
@ivar _impl: The implementation of L{_IKQueue} to use.
@ivar _selectables: A dictionary mapping integer file descriptors to
instances of L{FileDescriptor} which have been registered with the
reactor. All L{FileDescriptor}s 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{_kq} for read readiness notifications
which will be dispatched to the corresponding L{FileDescriptor}
instances in C{_selectables}.
@ivar _writes: A set containing integer file descriptors. Values in this
set will be registered with C{_kq} for write readiness notifications
which will be dispatched to the corresponding L{FileDescriptor}
instances in C{_selectables}.
c �� � || _ | j j � | _ t � | _ t � | _ i | _ t j j | � y)a�
Initialize kqueue object, file descriptor tracking dictionaries, and
the base class.
See:
- http://docs.python.org/library/select.html
- www.freebsd.org/cgi/man.cgi?query=kqueue
- people.freebsd.org/~jlemon/papers/kqueue.pdf
@param _kqueueImpl: The implementation of L{_IKQueue} to use. A
hook for testing.
N)
�_implr �_kq�set�_reads�_writes�_selectablesr �PosixReactorBase�__init__)�self�_kqueueImpls r r' |