NNGAio

{NNGAio} Async IO poller for many purposes. Contains the NNGMessage payload and optional context pointer. General usage - inter-thread communication. Properties: - pointer: to read the internal nng_aio pointer - pointer: to set the nng_aio pointer to external one - context: to read the stored context - count: number of bytes transfwred by the AIO operation - result: result of the AIO operation - zero or error code - timeout: to set teh poll timeout Methods: - constructor -- callback pointer: function or delegate void (void*) -- argument pointer: to be sent to callback -- context pointer: to store and retrieve - realloc: same agruments as constructor - to reuse and rearm aio - begin: begin postponed AIO aopertion - wait: block until AIO success or error or timeout - sleep: performs an asynchronous "sleep", causing the callback for aio to be executed after delay - abort: abort immediately, return error as result but call callback - cancel: like abort with predefined error NNG_ECANCELED - stop: like cancel but prevent callback from calling, except it is already running - get_msg: extract NNGMessage passed to the AIO - set_msg: push NNGMessage to aio before start operation - clear_msg: clear stored NNGMessage TODO: implement [get/set] input/output/iov

Constructors

this
this(T cb, void* arg, void* ctx)

Creator for both function and delegate callbacks Param: - callback pointer - callback argument pointer - context pointer to store

this
this(nng_aio* src)

Creator to copy internal nng_aio structure

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

abort
void abort(nng_errno err)

= no callback

cancel
void cancel()

= abort(NNG_CANCELLED) = no callback = no wait for abort and callback complete

clear_msg
void clear_msg()

Clear message slot

finish
void finish(nng_errno err)

= callback

get_msg
nng_errno get_msg(NNGMessage msg)

Get NNGMessage after AIO

realloc
void realloc(T cb, void* arg, void* ctx)

Realloc and reuse object

set_msg
void set_msg(NNGMessage msg)

Set NNGMessage to transfer to AIO

sleep
void sleep(Duration val)

Poller sleep

stop
void stop()

= abort(NNG_CANCELLED) = no callback = wait for abort and callback complete

wait
void wait()

Poller wait

Properties

context
void* context [@property getter]

Context getter

context
void* context [@property setter]

Context setter

count
size_t count [@property getter]

Returns count of bytes transferred through AIO

pointer
nng_aio* pointer [@property getter]

Internal pointer getter

pointer
nng_aio* pointer [@property setter]

Internal pointer setter

result
nng_errno result [@property getter]

Returns AIO status - zero or error code

timeout
Duration timeout [@property setter]

Set AIO timeout