mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +00:00
Implements `asyncdispatch.getIoHandler` and assert on nil futures.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user