summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@gmail.com>2017-11-24 16:30:56 +0000
committerDominik Picheta <dominikpicheta@gmail.com>2017-11-24 16:30:56 +0000
commit325e4520ec74cd49a21c389bb2d137a74536f062 (patch)
tree8f378c0e0a857b3c42b57df5fb7be5b98e4aa3ea /lib
parente5a27c96fbd8a3bdd48b1974595381c1a335aaa5 (diff)
downloadNim-325e4520ec74cd49a21c389bb2d137a74536f062.tar.gz
Implements ``asyncdispatch.getIoHandler`` and assert on nil futures.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/asyncdispatch.nim8
-rw-r--r--lib/pure/asyncfutures.nim1
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim
index 7211fabc7..cee692980 100644
--- a/lib/pure/asyncdispatch.nim
+++ b/lib/pure/asyncdispatch.nim
@@ -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:
diff --git a/lib/pure/asyncfutures.nim b/lib/pure/asyncfutures.nim
index bebd19611..8941dca6e 100644
--- a/lib/pure/asyncfutures.nim
+++ b/lib/pure/asyncfutures.nim
@@ -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: