<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12098] twext/trunk/twext/internet/kqreactor.py</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12098">12098</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2013-12-13 17:09:25 -0800 (Fri, 13 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Obsolete.</pre>

<h3>Removed Paths</h3>
<ul>
<li><a href="#twexttrunktwextinternetkqreactorpy">twext/trunk/twext/internet/kqreactor.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="twexttrunktwextinternetkqreactorpy"></a>
<div class="delfile"><h4>Deleted: twext/trunk/twext/internet/kqreactor.py (12097 => 12098)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/internet/kqreactor.py        2013-12-14 01:08:33 UTC (rev 12097)
+++ twext/trunk/twext/internet/kqreactor.py        2013-12-14 01:09:25 UTC (rev 12098)
</span><span class="lines">@@ -1,228 +0,0 @@
</span><del>-# Copyright (c) 2001-2008 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-
-&quot;&quot;&quot;
-A kqueue()/kevent() 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 kqreactor
-    | kqreactor.install()
-
-
-Maintainer: U{Itamar Shtull-Trauring&lt;mailto:twisted@itamarst.org&gt;}
-&quot;&quot;&quot;
-
-
-import errno, sys
-
-try:
-    from select import KQ_FILTER_READ, KQ_FILTER_WRITE, KQ_EV_DELETE, KQ_EV_ADD
-    from select import kqueue, kevent, KQ_EV_ENABLE, KQ_EV_DISABLE, KQ_EV_EOF
-except ImportError:
-    from select26 import KQ_FILTER_READ, KQ_FILTER_WRITE, KQ_EV_DELETE, KQ_EV_ADD
-    from select26 import kqueue, kevent, KQ_EV_ENABLE, KQ_EV_DISABLE, KQ_EV_EOF
-
-from zope.interface import implements
-
-from twisted.python import log
-from twisted.internet import main, posixbase
-from twisted.internet.interfaces import IReactorFDSet
-
-
-
-class KQueueReactor(posixbase.PosixReactorBase):
-    &quot;&quot;&quot;
-    A reactor that uses kqueue(2)/kevent(2).
-
-    @ivar _kq: A L{kqueue} 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 set storing integer file descriptors.  These values 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 storing integer file descriptors.  These values will
-        be registered with C{_kq} for write readiness notifications which will
-        be dispatched to the corresponding L{FileDescriptor} instances in
-        C{_selectables}.
-    &quot;&quot;&quot;
-    implements(IReactorFDSet)
-
-    def __init__(self):
-        &quot;&quot;&quot;
-        Initialize kqueue object, file descriptor tracking sets, and the base
-        class.
-        &quot;&quot;&quot;
-        self._kq = kqueue()
-        self._reads = set()
-        self._writes = set()
-        self._selectables = {}
-        posixbase.PosixReactorBase.__init__(self)
-
-
-    def _updateRegistration(self, fd, filter, flags):
-        ev = kevent(fd, filter, flags)
-        self._kq.control([ev], 0, 0)
-
-
-    def addReader(self, reader):
-        &quot;&quot;&quot;
-        Add a FileDescriptor for notification of data available to read.
-        &quot;&quot;&quot;
-        fd = reader.fileno()
-        if fd not in self._reads:
-            if fd not in self._selectables:
-                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ADD|KQ_EV_ENABLE)
-                self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_ADD|KQ_EV_DISABLE)
-                self._selectables[fd] = reader
-            else:
-                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ENABLE)
-            self._reads.add(fd)
-
-
-    def addWriter(self, writer):
-        &quot;&quot;&quot;
-        Add a FileDescriptor for notification of data available to write.
-        &quot;&quot;&quot;
-        fd = writer.fileno()
-        if fd not in self._writes:
-            if fd not in self._selectables:
-                self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_ADD|KQ_EV_ENABLE)
-                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ADD|KQ_EV_DISABLE)
-                self._selectables[fd] = writer
-            else:
-                self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_ENABLE)
-            self._writes.add(fd)
-
-
-    def removeReader(self, reader):
-        &quot;&quot;&quot;
-        Remove a Selectable for notification of data available to read.
-        &quot;&quot;&quot;
-        fd = reader.fileno()
-        if fd == -1:
-            for fd, fdes in self._selectables.iteritems():
-                if reader is fdes:
-                    break
-            else:
-                return
-        if fd in self._reads:
-            self._reads.discard(fd)
-            if fd not in self._writes:
-                del self._selectables[fd]
-            self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_DISABLE)
-
-
-    def removeWriter(self, writer):
-        &quot;&quot;&quot;
-        Remove a Selectable for notification of data available to write.
-        &quot;&quot;&quot;
-        fd = writer.fileno()
-        if fd == -1:
-            for fd, fdes in self._selectables.iteritems():
-                if writer is fdes:
-                    break
-            else:
-                return
-        if fd in self._writes:
-            self._writes.discard(fd)
-            if fd not in self._reads:
-                del self._selectables[fd]
-            self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_DISABLE)
-
-
-    def removeAll(self):
-        &quot;&quot;&quot;
-        Remove all selectables, and return a list of them.
-        &quot;&quot;&quot;
-        if self.waker is not None:
-            self.removeReader(self.waker)
-        result = self._selectables.values()
-        for fd in self._reads:
-            self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_DELETE)
-        for fd in self._writes:
-            self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_DELETE)
-        self._reads.clear()
-        self._writes.clear()
-        self._selectables.clear()
-        if self.waker is not None:
-            self.addReader(self.waker)
-        return result
-
-
-    def getReaders(self):
-        return [self._selectables[fd] for fd in self._reads]
-
-
-    def getWriters(self):
-        return [self._selectables[fd] for fd in self._writes]
-
-
-    def doKEvent(self, timeout):
-        &quot;&quot;&quot;
-        Poll the kqueue for new events.
-        &quot;&quot;&quot;
-        if timeout is None:
-            timeout = 1
-
-        try:
-            l = self._kq.control([], len(self._selectables), timeout)
-        except OSError, e:
-            if e[0] == errno.EINTR:
-                return
-            else:
-                raise
-        _drdw = self._doWriteOrRead
-        for event in l:
-            fd = event.ident
-            try:
-                selectable = self._selectables[fd]
-            except KeyError:
-                # Handles the infrequent case where one selectable's
-                # handler disconnects another.
-                continue
-            log.callWithLogger(selectable, _drdw, selectable, fd, event)
-
-
-    def _doWriteOrRead(self, selectable, fd, event):
-        why = None
-        inRead = False
-        filter, flags, data, fflags = event.filter, event.flags, event.data, event.fflags
-        if flags &amp; KQ_EV_EOF and data and fflags:
-            why = main.CONNECTION_LOST
-        else:
-            try:
-                if filter == KQ_FILTER_READ:
-                    inRead = True
-                    why = selectable.doRead()
-                if filter == KQ_FILTER_WRITE:
-                    inRead = False
-                    why = selectable.doWrite()
-                if not selectable.fileno() == fd:
-                    inRead = False
-                    why = main.CONNECTION_LOST
-            except:
-                log.err()
-                why = sys.exc_info()[1]
-
-        if why:
-            self._disconnectSelectable(selectable, why, inRead)
-
-    doIteration = doKEvent
-
-
-def install():
-    k = KQueueReactor()
-    main.installReactor(k)
-
-
-__all__ = [&quot;KQueueReactor&quot;, &quot;install&quot;]
</del></span></pre>
</div>
</div>

</body>
</html>