diff options
author | Adam Strzelecki <ono@java.pl> | 2015-09-29 19:28:10 +0200 |
---|---|---|
committer | Adam Strzelecki <ono@java.pl> | 2015-09-29 19:28:10 +0200 |
commit | 4c537bd1e5bf44a50c4a5935faef98318a448929 (patch) | |
tree | e744fd5d8591056478772e8353aae37e89e36333 | |
parent | 248f52fea7f22beac1ac75022b6b4d49964f6071 (diff) | |
download | Nim-4c537bd1e5bf44a50c4a5935faef98318a448929.tar.gz |
selectors: Cleanup a bit epoll flavor
1. Remove select documentation that is duplicate of nimdoc section below 2. Simplify a bit register proc code
-rw-r--r-- | lib/pure/selectors.nim | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim index 2ee8f1180..ca969c761 100644 --- a/lib/pure/selectors.nim +++ b/lib/pure/selectors.nim @@ -81,7 +81,6 @@ when defined(nimdoc): proc `[]`*(s: Selector, fd: SocketHandle): SelectorKey = ## Retrieves the selector key for ``fd``. - elif defined(linux): type Selector* = object @@ -101,15 +100,13 @@ elif defined(linux): result.data.fd = fd.cint proc register*(s: var Selector, fd: SocketHandle, events: set[Event], - data: SelectorData) = + data: SelectorData) = var event = createEventStruct(events, fd) if events != {}: if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fd, addr(event)) != 0: raiseOSError(osLastError()) - var key = SelectorKey(fd: fd, events: events, data: data) - - s.fds[fd] = key + s.fds[fd] = SelectorKey(fd: fd, events: events, data: data) proc update*(s: var Selector, fd: SocketHandle, events: set[Event]) = if s.fds[fd].events != events: @@ -156,11 +153,6 @@ elif defined(linux): raiseOSError(err) proc select*(s: var Selector, timeout: int): seq[ReadyInfo] = - ## - ## The ``events`` field of the returned ``key`` contains the original events - ## for which the ``fd`` was bound. This is contrary to the ``events`` field - ## of the ``TReadyInfo`` tuple which determines which events are ready - ## on the ``fd``. result = @[] let evNum = epoll_wait(s.epollFD, addr s.events[0], 64.cint, timeout.cint) if evNum < 0: |