diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-31 17:59:01 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-09-22 11:47:07 -0700 |
| commit | d72076207a2fad96ff014a81366868fb47a0ed1b (patch) | |
| tree | 5a4f67ab607ef6690e983c2d1ab2c64062027e52 /src/core/aio.h | |
| parent | 366f3e5d14c5f891655ad1fa2b3cfa9a56b8830d (diff) | |
| download | nng-d72076207a2fad96ff014a81366868fb47a0ed1b.tar.gz nng-d72076207a2fad96ff014a81366868fb47a0ed1b.tar.bz2 nng-d72076207a2fad96ff014a81366868fb47a0ed1b.zip | |
Allocate AIOs dynamically.
We allocate AIO structures dynamically, so that we can use them
abstractly in more places without inlining them. This will be used
for the ZeroTier transport to allow us to create operations consisting
of just the AIO. Furthermore, we provide accessors for some of the
aio members, in the hopes that we will be able to wrap these for
"safe" version of the AIO capability to export to applications, and
to protocol and transport implementors.
While here we cleaned up the protocol details to use consistently
shorter names (no nni_ prefix for static symbols needed), and we
also fixed a bug in the surveyor code.
Diffstat (limited to 'src/core/aio.h')
| -rw-r--r-- | src/core/aio.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/core/aio.h b/src/core/aio.h index 9114c9fe..eae17446 100644 --- a/src/core/aio.h +++ b/src/core/aio.h @@ -52,6 +52,9 @@ struct nni_aio { // Resolver operations. nni_sockaddr *a_addr; + // Extra user data. + void *a_data; + // Provider-use fields. nni_aio_cancelfn a_prov_cancel; void * a_prov_data; @@ -65,7 +68,7 @@ struct nni_aio { // the supplied argument when the operation is complete. If NULL is // supplied for the callback, then nni_aio_wake is used in its place, // and the aio is used for the argument. -extern void nni_aio_init(nni_aio *, nni_cb, void *); +extern int nni_aio_init(nni_aio **, nni_cb, void *); // nni_aio_fini finalizes the aio, releasing resources (locks) // associated with it. The caller is responsible for ensuring that any @@ -83,6 +86,27 @@ extern void nni_aio_fini(nni_aio *); // use nni_aio_cancel instead.) extern void nni_aio_stop(nni_aio *); +// nni_aio_set_data sets user data. This should only be done by the +// consumer, initiating the I/O. The intention is to be able to store +// additional data for use when the operation callback is executed. +extern void nni_aio_set_data(nni_aio *, void *); + +// nni_aio_get_data returns the user data that was previously stored +// with nni_aio_set_data. +extern void *nni_aio_get_data(nni_aio *); + +extern void nni_aio_set_msg(nni_aio *, nni_msg *); +extern nni_msg *nni_aio_get_msg(nni_aio *); +extern void nni_aio_set_pipe(nni_aio *, void *); +extern void * nni_aio_get_pipe(nni_aio *); +extern void nni_aio_set_ep(nni_aio *, void *); +extern void * nni_aio_get_ep(nni_aio *); + +// nni_aio_set_timeout sets the timeout (absolute) when the AIO will +// be canceled. The cancelation does not happen until after nni_aio_start +// is called. +extern void nni_aio_set_timeout(nni_aio *, nni_time); + // nni_aio_result returns the result code (0 on success, or an NNG errno) // for the operation. It is only valid to call this when the operation is // complete (such as when the callback is executed or after nni_aio_wait |
