Implements `asyncdispatch.getIoHandler` and assert on nil futures.

This commit is contained in:
Dominik Picheta
2017-11-24 16:30:56 +00:00
parent e5a27c96fb
commit 325e4520ec
3 changed files with 12 additions and 0 deletions

View File

@@ -23,6 +23,9 @@
in the async dispatcher.
- Implemented an `accept` proc that works on a `SocketHandle` in
``nativesockets``.
- Implemented ``getIoHandler`` proc in the ``asyncdispatch`` module that allows
you to retrieve the underlying IO Completion Port or ``Selector[AsyncData]``
object in the specified dispatcher.
- The overloading rules changed slightly so that constrained generics are
preferred over unconstrained generics. (Bug #6526)
- It is now possible to forward declare object types so that mutually

View File

@@ -262,6 +262,11 @@ when defined(windows) or defined(nimdoc):
setGlobalDispatcher(newDispatcher())
result = gDisp
proc getIoHandler*(disp: PDispatcher): Handle =
## Returns the underlying IO Completion Port handle (Windows) or selector
## (Unix) for the specified dispatcher.
return disp.ioPort
proc register*(fd: cint | SocketHandle | AsyncFD): AsyncFD {.discardable.} =
## Registers ``fd`` with the dispatcher.
##
@@ -1103,6 +1108,9 @@ else:
setGlobalDispatcher(newDispatcher())
result = gDisp
proc getIoHandler*(disp: PDispatcher): Selector[AsyncData] =
return disp.selector
proc register*(fd: cint | SocketHandle | AsyncFD): AsyncFD {.discardable.} =
let p = getGlobalDispatcher()
when fd is AsyncFD:

View File

@@ -281,6 +281,7 @@ proc asyncCheck*[T](future: Future[T]) =
## finished with an error.
##
## This should be used instead of ``discard`` to discard void futures.
assert(not future.isNil, "Future is nil")
future.callback =
proc () =
if future.failed: