Types
AsyncZPollCB = proc (x: ZSocket) {....gcsafe.}
AsyncZPoller = object cb*: seq[AsyncZPollCB] zpoll*: ZPoller
- Experimental type to use zmq.poll() with Nim's async dispatch loop
Procs
proc `=destroy`(obj: AsyncZPoller) {....raises: [], tags: [TimeEffect, RootEffect], forbids: [].}
proc initZPoller(args: openArray[tuple[item: ZConnection, cb: AsyncZPollCB]]; event: cshort): AsyncZPoller {....raises: [], tags: [], forbids: [].}
- Init a ZPoller with all items on the same event
proc initZPoller(poller: sink ZPoller; cb: AsyncZPollCB): AsyncZPoller {. ...raises: [], tags: [], forbids: [].}
proc len(poller: AsyncZPoller): int {....raises: [], tags: [], forbids: [].}
proc pollAsync(poller: AsyncZPoller; timeout: int = 2): Future[int] {. ...raises: [ValueError, Exception, OSError], tags: [TimeEffect, RootEffect], forbids: [].}
- Experimental API. Poll all the ZConnection and execute an async CB when event occurs.
proc receiveAsync(conn: ZConnection): Future[string] {. ...raises: [ValueError, ZmqError, OSError, Exception], tags: [RootEffect], forbids: [].}
-
Similar to receive(), but receiveAsync() allows other async tasks to run. receiveAsync() allows other async tasks to run in those cases.
This will not work in some case because it depends on ZMQ_FD which is not necessarily the 'true' FD of the socket
See https://github.com/zeromq/libzmq/issues/2941 and https://github.com/zeromq/pyzmq/issues/1411
proc register(poller: var AsyncZPoller; conn: ZConnection; event: int; cb: AsyncZPollCB) {....raises: [], tags: [], forbids: [].}
- Register ZConnection
proc register(poller: var AsyncZPoller; item: ZPollItem; cb: AsyncZPollCB) {. ...raises: [], tags: [], forbids: [].}
- Register ZConnection
proc register(poller: var AsyncZPoller; sock: ZSocket; event: int; cb: AsyncZPollCB) {....raises: [], tags: [], forbids: [].}
- Register ZSocket function
proc sendAsync(conn: ZConnection; msg: string; flags: ZSendRecvOptions = DONTWAIT): Future[void] {. ...raises: [ValueError, ZmqError, OSError, Exception], tags: [RootEffect], forbids: [].}
-
send() is blocking for some connection types (e.g. PUSH, DEALER). sendAsync() allows other async tasks to run in those cases.
This will not work in some case because it depends on ZMQ_FD which is not necessarily the 'true' FD of the socket
See https://github.com/zeromq/libzmq/issues/2941 and https://github.com/zeromq/pyzmq/issues/1411