aboutsummaryrefslogtreecommitdiff
path: root/src/nng.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nng.h')
-rw-r--r--src/nng.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nng.h b/src/nng.h
index 50e557a4..6bc38c90 100644
--- a/src/nng.h
+++ b/src/nng.h
@@ -564,6 +564,11 @@ NNG_DECL void nng_aio_set_timeout(nng_aio *, nng_duration);
// to succeed if n <= 4, otherwise it may fail due to NNG_ENOMEM.
NNG_DECL int nng_aio_set_iov(nng_aio *, unsigned, const nng_iov *);
+// nng_aio_begin is called by the provider to mark the operation as
+// beginning. If it returns false, then the provider must take no
+// further action on the aio.
+NNG_DECL bool nng_aio_begin(nng_aio *);
+
// nng_aio_finish is used to "finish" an asynchronous operation.
// It should only be called by "providers" (such as HTTP server API users).
// The argument is the value that nng_aio_result() should return.
@@ -571,6 +576,19 @@ NNG_DECL int nng_aio_set_iov(nng_aio *, unsigned, const nng_iov *);
// given aio.
NNG_DECL void nng_aio_finish(nng_aio *, int);
+// nng_aio_defer is used to register a cancellation routine, and indicate
+// that the operation will be completed asynchronously. It must only be
+// called once per operation on an aio, and must only be called by providers.
+// If the operation is canceled by the consumer, the cancellation callback
+// will be called. The provider *must* still ensure that the nng_aio_finish()
+// function is called EXACTLY ONCE. If the operation cannot be canceled
+// for any reason, the cancellation callback should do nothing. The
+// final argument is passed to the cancelfn. The final argument of the
+// cancellation function is the error number (will not be zero) corresponding
+// to the reason for cancellation, e.g. NNG_ETIMEDOUT or NNG_ECANCELED.
+typedef void (*nng_aio_cancelfn)(nng_aio *, void *, int);
+NNG_DECL void nng_aio_defer(nng_aio *, nng_aio_cancelfn, void *);
+
// nng_aio_sleep does a "sleeping" operation, basically does nothing
// but wait for the specified number of milliseconds to expire, then
// calls the callback. This returns 0, rather than NNG_ETIMEDOUT.