diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-02-24 16:00:11 +0000 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-02-24 16:00:11 +0000 |
commit | deb3729cb7a6960b4a0a095d2a771df99e52d1a8 (patch) | |
tree | ced593d65f9bb464ca583cea2d78b3120ca9e1a6 /lib/pure/selectors.nim | |
parent | 7324ed7f1fb5a265de57c95e08a5b4044c662d0e (diff) | |
parent | 7898e91c32acb99025cf7e0d2261f0e7039ba95b (diff) | |
download | Nim-deb3729cb7a6960b4a0a095d2a771df99e52d1a8.tar.gz |
Merge pull request #2207 from def-/netstuff
Netstuff
Diffstat (limited to 'lib/pure/selectors.nim')
-rw-r--r-- | lib/pure/selectors.nim | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim index 2ed53ef3f..b6bc9dd3a 100644 --- a/lib/pure/selectors.nim +++ b/lib/pure/selectors.nim @@ -48,12 +48,21 @@ when defined(nimdoc): events: set[Event]): SelectorKey {.discardable.} = ## Updates the events which ``fd`` wants notifications for. + proc unregister*(s: Selector, fd: SocketHandle): SelectorKey {.discardable.} = + ## Unregisters file descriptor ``fd`` from selector ``s``. + + proc close*(s: Selector) = + ## Closes the selector + proc select*(s: 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``. + proc newSelector*(): Selector = + ## Creates a new selector + proc contains*(s: Selector, fd: SocketHandle): bool = ## Determines whether selector contains a file descriptor. @@ -78,8 +87,6 @@ elif defined(linux): proc register*(s: Selector, fd: SocketHandle, events: set[Event], data: RootRef): SelectorKey {.discardable.} = - ## Registers file descriptor ``fd`` to selector ``s`` with a set of TEvent - ## ``events``. var event = createEventStruct(events, fd) if events != {}: if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fd, addr(event)) != 0: @@ -92,7 +99,6 @@ elif defined(linux): proc update*(s: Selector, fd: SocketHandle, events: set[Event]): SelectorKey {.discardable.} = - ## Updates the events which ``fd`` wants notifications for. if s.fds[fd].events != events: if events == {}: # This fd is idle -- it should not be registered to epoll. @@ -204,7 +210,6 @@ elif not defined(nimdoc): proc update*(s: Selector, fd: SocketHandle, events: set[Event]): SelectorKey {.discardable.} = - ## Updates the events which ``fd`` wants notifications for. if not s.fds.hasKey(fd): raise newException(ValueError, "File descriptor not found.") |