Implements `asyncdispatch.getIoHandler` and assert on nil futures.
This commit is contained in:
parent
e5a27c96fb
commit
325e4520ec
3 changed files with 12 additions and 0 deletions
|
|
@ -23,6 +23,9 @@
|
||||||
in the async dispatcher.
|
in the async dispatcher.
|
||||||
- Implemented an `accept` proc that works on a `SocketHandle` in
|
- Implemented an `accept` proc that works on a `SocketHandle` in
|
||||||
``nativesockets``.
|
``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
|
- The overloading rules changed slightly so that constrained generics are
|
||||||
preferred over unconstrained generics. (Bug #6526)
|
preferred over unconstrained generics. (Bug #6526)
|
||||||
- It is now possible to forward declare object types so that mutually
|
- It is now possible to forward declare object types so that mutually
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,11 @@ when defined(windows) or defined(nimdoc):
|
||||||
setGlobalDispatcher(newDispatcher())
|
setGlobalDispatcher(newDispatcher())
|
||||||
result = gDisp
|
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.} =
|
proc register*(fd: cint | SocketHandle | AsyncFD): AsyncFD {.discardable.} =
|
||||||
## Registers ``fd`` with the dispatcher.
|
## Registers ``fd`` with the dispatcher.
|
||||||
##
|
##
|
||||||
|
|
@ -1103,6 +1108,9 @@ else:
|
||||||
setGlobalDispatcher(newDispatcher())
|
setGlobalDispatcher(newDispatcher())
|
||||||
result = gDisp
|
result = gDisp
|
||||||
|
|
||||||
|
proc getIoHandler*(disp: PDispatcher): Selector[AsyncData] =
|
||||||
|
return disp.selector
|
||||||
|
|
||||||
proc register*(fd: cint | SocketHandle | AsyncFD): AsyncFD {.discardable.} =
|
proc register*(fd: cint | SocketHandle | AsyncFD): AsyncFD {.discardable.} =
|
||||||
let p = getGlobalDispatcher()
|
let p = getGlobalDispatcher()
|
||||||
when fd is AsyncFD:
|
when fd is AsyncFD:
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,7 @@ proc asyncCheck*[T](future: Future[T]) =
|
||||||
## finished with an error.
|
## finished with an error.
|
||||||
##
|
##
|
||||||
## This should be used instead of ``discard`` to discard void futures.
|
## This should be used instead of ``discard`` to discard void futures.
|
||||||
|
assert(not future.isNil, "Future is nil")
|
||||||
future.callback =
|
future.callback =
|
||||||
proc () =
|
proc () =
|
||||||
if future.failed:
|
if future.failed:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue