aboutsummaryrefslogtreecommitdiff
path: root/docs/man/nng_aio_defer.3.adoc
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-08-20 11:09:23 -0700
committerGarrett D'Amore <garrett@damore.org>2018-08-20 11:09:23 -0700
commitc72bd53e2c5b4bc7207bfa1710ccff47655a099a (patch)
treef85e26882244430c41930c45d83887d5b01969cc /docs/man/nng_aio_defer.3.adoc
parent6e5f6a26beec0a44d25625cacb5095cdc7a94146 (diff)
downloadnng-c72bd53e2c5b4bc7207bfa1710ccff47655a099a.tar.gz
nng-c72bd53e2c5b4bc7207bfa1710ccff47655a099a.tar.bz2
nng-c72bd53e2c5b4bc7207bfa1710ccff47655a099a.zip
fixes #506 AIO "providers" need a way to call nni_aio_schedule.
Diffstat (limited to 'docs/man/nng_aio_defer.3.adoc')
-rw-r--r--docs/man/nng_aio_defer.3.adoc78
1 files changed, 78 insertions, 0 deletions
diff --git a/docs/man/nng_aio_defer.3.adoc b/docs/man/nng_aio_defer.3.adoc
new file mode 100644
index 00000000..67520293
--- /dev/null
+++ b/docs/man/nng_aio_defer.3.adoc
@@ -0,0 +1,78 @@
+= nng_aio_defer(3)
+//
+// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+//
+// This document is supplied under the terms of the MIT License, a
+// copy of which should be located in the distribution where this
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
+
+== NAME
+
+nng_aio_defer - defer asynchronous I/O operation
+
+== SYNOPSIS
+
+[source, c]
+----
+#include <nng/nng.h>
+
+typedef void (*nng_aio_cancelfn)(nng_aio *aio, void *arg, int err);
+
+void nng_aio_defer(nng_aio *aio, nng_aio_cancelfn fn, void *arg);
+----
+
+== DESCRIPTION
+
+The `nng_aio_defer()` function marks operation associated with _aio_ as
+being deferred for asynchronous completion, and also registers a cancellation
+function _fn_ and associated argument _arg_, thereby
+permitting the operation to be canceled.
+
+If the _aio_ is being canceled, the cancellation routine _fn_ will be called
+with the _aio_, the _arg_ specified by `nng_aio_defer()`, and an error
+value in _err_, which is the reason that the operation is being canceled.
+
+The operation may not be cancelable; for example it may have already been
+completed, or be in a state where it is no longer possible to unschedule it.
+In this case, the _cancelfn_ should just return without making any changes.
+
+If the cancellation routine successfully canceled the operation, it should
+ensure that `<<nng_aio_finish.3#,nng_aio_finish()>>` is called, with the
+error code specified by _err_.
+
+IMPORTANT: It is mandatory that I/O providers call
+`<<nng_aio_finish.3#,nng_aio_finish()>>`
+*EXACTLY ONCE* when they are finished with the operation.
+
+NOTE: This function is only for I/O providers (those actually performing
+the operation such as HTTP handler functions or transport providers); ordinary
+users of the _aio_ should not call this function.
+
+NOTE: Care must be taken to ensure that cancellation and completion of
+the routine are multi-thread safe; this will usually involve the use
+of locks or other synchronization primitives.
+
+TIP: For operations that complete synchronously, without any need to be
+deferred, the provider should not bother to call `nng_aio_defer()`,
+although it is harmless if it does.
+
+== RETURN VALUES
+
+None.
+
+== ERRORS
+
+None.
+
+== SEE ALSO
+
+[.text-left]
+<<nng_aio_alloc.3#,nng_aio_alloc(3)>>,
+<<nng_aio_cancel.3#,nng_aio_cancel(3)>>,
+<<nng_aio_finish.3#,nng_aio_finish(3)>>,
+<<nng_aio_result.3#,nng_aio_result(3)>>,
+<<nng_aio.5#,nng_aio(5)>>,
+<<nng.7#,nng(7)>>