aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-11-09 23:20:38 -0800
committerGarrett D'Amore <garrett@damore.org>2020-11-09 23:20:38 -0800
commitaf4c08675825fbf28f64b6ea4af6a1b9f0576f23 (patch)
treeb7349ef6889623d6c1962ad9740f8cb5ab0bc0dc /src/core
parent2a55e0a279a0b94e204e0ffead73505100a0481f (diff)
downloadnng-af4c08675825fbf28f64b6ea4af6a1b9f0576f23.tar.gz
nng-af4c08675825fbf28f64b6ea4af6a1b9f0576f23.tar.bz2
nng-af4c08675825fbf28f64b6ea4af6a1b9f0576f23.zip
Minor spelling tweaks for the aio framework.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/aio.c86
-rw-r--r--src/core/aio.h29
2 files changed, 58 insertions, 57 deletions
diff --git a/src/core/aio.c b/src/core/aio.c
index 6a390677..676199a5 100644
--- a/src/core/aio.c
+++ b/src/core/aio.c
@@ -16,7 +16,7 @@ static nni_mtx nni_aio_lk;
static nni_cv nni_aio_expire_cv;
static int nni_aio_expire_run;
static nni_thr nni_aio_expire_thr;
-static nni_list nni_aio_expire_aios;
+static nni_list nni_aio_expire_list;
static nni_aio *nni_aio_expire_aio;
// Design notes.
@@ -41,7 +41,7 @@ static nni_aio *nni_aio_expire_aio;
// expiring, and wait for that record to be cleared (or at least not
// equal to the aio) before destroying it.
//
-// The aio framework is tightly bound up with the taskq framework. We
+// The aio framework is tightly bound up with the task framework. We
// "prepare" the task for an aio when a caller marks an aio as starting
// (with nni_aio_begin), and that marks the task as busy. Then, all we have
// to do is wait for the task to complete (the busy flag to be cleared)
@@ -75,7 +75,7 @@ nni_aio_init(nni_aio *aio, nni_cb cb, void *arg)
void
nni_aio_fini(nni_aio *aio)
{
- nni_aio_cancelfn fn;
+ nni_aio_cancel_fn fn;
void * arg;
// TODO: This probably could just use nni_aio_stop.
@@ -113,7 +113,7 @@ nni_aio_fini(nni_aio *aio)
}
int
-nni_aio_alloc(nni_aio **aiop, nni_cb cb, void *arg)
+nni_aio_alloc(nni_aio **aio_p, nni_cb cb, void *arg)
{
nni_aio *aio;
@@ -121,7 +121,7 @@ nni_aio_alloc(nni_aio **aiop, nni_cb cb, void *arg)
return (NNG_ENOMEM);
}
nni_aio_init(aio, cb, arg);
- *aiop = aio;
+ *aio_p = aio;
return (0);
}
@@ -135,21 +135,21 @@ nni_aio_free(nni_aio *aio)
}
int
-nni_aio_set_iov(nni_aio *aio, unsigned niov, const nni_iov *iov)
+nni_aio_set_iov(nni_aio *aio, unsigned nio, const nni_iov *iov)
{
- if (niov > NNI_NUM_ELEMENTS((aio->a_iov))) {
+ if (nio > NNI_NUM_ELEMENTS((aio->a_iov))) {
return (NNG_EINVAL);
}
// Sometimes we are resubmitting our own io vector, with
// just a smaller count. We copy them only if we are not.
if (iov != &aio->a_iov[0]) {
- for (unsigned i = 0; i < niov; i++) {
+ for (unsigned i = 0; i < nio; i++) {
aio->a_iov[i] = iov[i];
}
}
- aio->a_niov = niov;
+ aio->a_nio = nio;
return (0);
}
@@ -163,7 +163,7 @@ void
nni_aio_stop(nni_aio *aio)
{
if (aio != NULL) {
- nni_aio_cancelfn fn;
+ nni_aio_cancel_fn fn;
void * arg;
nni_mtx_lock(&nni_aio_lk);
@@ -186,7 +186,7 @@ void
nni_aio_close(nni_aio *aio)
{
if (aio != NULL) {
- nni_aio_cancelfn fn;
+ nni_aio_cancel_fn fn;
void * arg;
nni_mtx_lock(&nni_aio_lk);
@@ -322,7 +322,7 @@ nni_aio_begin(nni_aio *aio)
}
int
-nni_aio_schedule(nni_aio *aio, nni_aio_cancelfn cancelfn, void *data)
+nni_aio_schedule(nni_aio *aio, nni_aio_cancel_fn cancel, void *data)
{
if (!aio->a_sleep) {
// Convert the relative timeout to an absolute timeout.
@@ -348,7 +348,7 @@ nni_aio_schedule(nni_aio *aio, nni_aio_cancelfn cancelfn, void *data)
}
NNI_ASSERT(aio->a_cancel_fn == NULL);
- aio->a_cancel_fn = cancelfn;
+ aio->a_cancel_fn = cancel;
aio->a_cancel_arg = data;
if (aio->a_expire != NNI_TIME_NEVER) {
@@ -363,7 +363,7 @@ nni_aio_schedule(nni_aio *aio, nni_aio_cancelfn cancelfn, void *data)
void
nni_aio_abort(nni_aio *aio, int rv)
{
- nni_aio_cancelfn fn;
+ nni_aio_cancel_fn fn;
void * arg;
nni_mtx_lock(&nni_aio_lk);
@@ -383,7 +383,7 @@ nni_aio_abort(nni_aio *aio, int rv)
static void
nni_aio_finish_impl(
- nni_aio *aio, int rv, size_t count, nni_msg *msg, bool synch)
+ nni_aio *aio, int rv, size_t count, nni_msg *msg, bool sync)
{
nni_mtx_lock(&nni_aio_lk);
@@ -401,7 +401,7 @@ nni_aio_finish_impl(
aio->a_sleep = false;
nni_mtx_unlock(&nni_aio_lk);
- if (synch) {
+ if (sync) {
nni_task_exec(&aio->a_task);
} else {
nni_task_dispatch(&aio->a_task);
@@ -415,7 +415,7 @@ nni_aio_finish(nni_aio *aio, int result, size_t count)
}
void
-nni_aio_finish_synch(nni_aio *aio, int result, size_t count)
+nni_aio_finish_sync(nni_aio *aio, int result, size_t count)
{
nni_aio_finish_impl(aio, result, count, NULL, true);
}
@@ -461,19 +461,19 @@ nni_aio_list_active(nni_aio *aio)
static void
nni_aio_expire_add(nni_aio *aio)
{
- nni_list *list = &nni_aio_expire_aios;
- nni_aio * naio;
+ nni_list *list = &nni_aio_expire_list;
+ nni_aio * prev;
// This is a reverse walk of the list. We're more likely to find
// a match at the end of the list.
- for (naio = nni_list_last(list); naio != NULL;
- naio = nni_list_prev(list, naio)) {
- if (aio->a_expire >= naio->a_expire) {
- nni_list_insert_after(list, aio, naio);
+ for (prev = nni_list_last(list); prev != NULL;
+ prev = nni_list_prev(list, prev)) {
+ if (aio->a_expire >= prev->a_expire) {
+ nni_list_insert_after(list, aio, prev);
break;
}
}
- if (naio == NULL) {
+ if (prev == NULL) {
// This has the shortest time, so insert at the start.
nni_list_prepend(list, aio);
// And, as we are the latest, kick the thing.
@@ -484,14 +484,14 @@ nni_aio_expire_add(nni_aio *aio)
static void
nni_aio_expire_loop(void *unused)
{
- nni_list *aios = &nni_aio_expire_aios;
+ nni_list *list = &nni_aio_expire_list;
NNI_ARG_UNUSED(unused);
nni_thr_set_name(NULL, "nng:aio:expire");
for (;;) {
- nni_aio_cancelfn fn;
+ nni_aio_cancel_fn fn;
nni_time now;
nni_aio * aio;
int rv;
@@ -500,7 +500,7 @@ nni_aio_expire_loop(void *unused)
nni_mtx_lock(&nni_aio_lk);
- if ((aio = nni_list_first(aios)) == NULL) {
+ if ((aio = nni_list_first(list)) == NULL) {
if (nni_aio_expire_run == 0) {
nni_mtx_unlock(&nni_aio_lk);
@@ -519,9 +519,9 @@ nni_aio_expire_loop(void *unused)
continue;
}
- // This aio's time has come. Expire it, canceling any
+ // The time has come for this aio. Expire it, canceling any
// outstanding I/O.
- nni_list_remove(aios, aio);
+ nni_list_remove(list, aio);
rv = aio->a_expire_ok ? 0 : NNG_ETIMEDOUT;
if ((fn = aio->a_cancel_fn) != NULL) {
@@ -560,10 +560,10 @@ nni_aio_set_prov_extra(nni_aio *aio, unsigned index, void *data)
}
void
-nni_aio_get_iov(nni_aio *aio, unsigned *niovp, nni_iov **iovp)
+nni_aio_get_iov(nni_aio *aio, unsigned *nio_p, nni_iov **iov_p)
{
- *niovp = aio->a_niov;
- *iovp = aio->a_iov;
+ *nio_p = aio->a_nio;
+ *iov_p = aio->a_iov;
}
void
@@ -583,33 +583,33 @@ nni_aio_bump_count(nni_aio *aio, size_t n)
size_t
nni_aio_iov_count(nni_aio *aio)
{
- size_t resid = 0;
+ size_t residual = 0;
- for (unsigned i = 0; i < aio->a_niov; i++) {
- resid += aio->a_iov[i].iov_len;
+ for (unsigned i = 0; i < aio->a_nio; i++) {
+ residual += aio->a_iov[i].iov_len;
}
- return (resid);
+ return (residual);
}
size_t
nni_aio_iov_advance(nni_aio *aio, size_t n)
{
- size_t resid = n;
+ size_t residual = n;
while (n) {
- NNI_ASSERT(aio->a_niov != 0);
+ NNI_ASSERT(aio->a_nio != 0);
if (aio->a_iov[0].iov_len > n) {
aio->a_iov[0].iov_len -= n;
NNI_INCPTR(aio->a_iov[0].iov_buf, n);
return (0); // we used all of "n"
}
- resid -= aio->a_iov[0].iov_len;
+ residual -= aio->a_iov[0].iov_len;
n -= aio->a_iov[0].iov_len;
- aio->a_niov--;
- for (unsigned i = 0; i < aio->a_niov; i++) {
+ aio->a_nio--;
+ for (unsigned i = 0; i < aio->a_nio; i++) {
aio->a_iov[i] = aio->a_iov[i + 1];
}
}
- return (resid); // we might not have used all of n for this iov
+ return (residual); // we might not have used all of n for this iov
}
static void
@@ -686,7 +686,7 @@ nni_aio_sys_init(void)
nni_cv * cv = &nni_aio_expire_cv;
nni_thr *thr = &nni_aio_expire_thr;
- NNI_LIST_INIT(&nni_aio_expire_aios, nni_aio, a_expire_node);
+ NNI_LIST_INIT(&nni_aio_expire_list, nni_aio, a_expire_node);
nni_mtx_init(mtx);
nni_cv_init(cv, mtx);
diff --git a/src/core/aio.h b/src/core/aio.h
index 2f699245..7e6a1741 100644
--- a/src/core/aio.h
+++ b/src/core/aio.h
@@ -16,7 +16,7 @@
#include "core/taskq.h"
#include "core/thread.h"
-typedef void (*nni_aio_cancelfn)(nni_aio *, void *, int);
+typedef void (*nni_aio_cancel_fn)(nni_aio *, void *, int);
// nni_aio_init initializes an aio object. The callback is called with
// the supplied argument when the operation is complete. If NULL is
@@ -35,7 +35,7 @@ extern void nni_aio_fini(nni_aio *);
extern int nni_aio_alloc(nni_aio **, nni_cb, void *arg);
// nni_aio_free frees the aio, releasing resources (locks)
-// associated with it. This is safe to call on zero'd memory.
+// associated with it. This is safe to call on zeroed memory.
// This must only be called on an object that was allocated
// with nni_aio_allocate.
extern void nni_aio_free(nni_aio *aio);
@@ -43,8 +43,8 @@ extern void nni_aio_free(nni_aio *aio);
// nni_aio_stop cancels any unfinished I/O, running completion callbacks,
// but also prevents any new operations from starting (nni_aio_start will
// return NNG_ESTATE). This should be called before nni_aio_free(). The
-// best pattern is to call nni_aio_stop on all linked aios, before calling
-// nni_aio_free on any of them. This function will block until any
+// best pattern is to call nni_aio_stop on all linked aio objects, before
+// calling nni_aio_free on any of them. This function will block until any
// callbacks are executed, and therefore it should never be executed
// from a callback itself. (To abort operations without blocking
// use nni_aio_cancel instead.)
@@ -53,7 +53,8 @@ extern void nni_aio_stop(nni_aio *);
// nni_aio_close closes the aio for further activity. It aborts any in-progress
// transaction (if it can), and future calls nni_aio_begin or nni_aio_schedule
// with both result in NNG_ECLOSED. The expectation is that protocols call this
-// for all their aios in a stop routine, before calling fini on any of them.
+// for all their aio objects in a stop routine, before calling fini on any of
+// them.
extern void nni_aio_close(nni_aio *);
// nni_aio_set_data sets user data. This should only be done by the
@@ -117,11 +118,11 @@ extern int nni_aio_list_active(nni_aio *);
// nni_aio_finish is called by the provider when an operation is complete.
extern void nni_aio_finish(nni_aio *, int, size_t);
-// nni_aio_finish_synch is to be called when a synchronous completion is
+// nni_aio_finish_sync is to be called when a synchronous completion is
// desired. It is very important that the caller not hold any locks when
// calling this, but it is useful for chaining completions to minimize
// context switch overhead during completions.
-extern void nni_aio_finish_synch(nni_aio *, int, size_t);
+extern void nni_aio_finish_sync(nni_aio *, int, size_t);
extern void nni_aio_finish_error(nni_aio *, int);
extern void nni_aio_finish_msg(nni_aio *, nni_msg *);
@@ -145,7 +146,7 @@ extern void nni_aio_set_prov_extra(nni_aio *, unsigned, void *);
// i.e. if the count refers to more data than the iov can support, then
// the result will be left over count.
extern size_t nni_aio_iov_advance(nni_aio *, size_t);
-// nni_aio_iov_count returns the number of bytes referenced by the aio's iov.
+// nni_aio_iov_count returns the number of bytes referenced by the aio iov.
extern size_t nni_aio_iov_count(nni_aio *);
extern int nni_aio_set_iov(nni_aio *, unsigned, const nni_iov *);
@@ -163,7 +164,7 @@ extern void nni_aio_bump_count(nni_aio *, size_t);
// is returned. (In that case the caller should probably either return an
// error to its caller, or possibly cause an asynchronous error by calling
// nni_aio_finish_error on this aio.)
-extern int nni_aio_schedule(nni_aio *, nni_aio_cancelfn, void *);
+extern int nni_aio_schedule(nni_aio *, nni_aio_cancel_fn, void *);
extern void nni_sleep_aio(nni_duration, nni_aio *);
@@ -188,7 +189,7 @@ struct nng_aio {
// Read/write operations.
nni_iov a_iov[8];
- unsigned a_niov;
+ unsigned a_nio;
// Message operations.
nni_msg *a_msg;
@@ -204,10 +205,10 @@ struct nng_aio {
void *a_outputs[4];
// Provider-use fields.
- nni_aio_cancelfn a_cancel_fn;
- void * a_cancel_arg;
- nni_list_node a_prov_node; // Linkage on provider list.
- void * a_prov_extra[2]; // Extra data used by provider
+ nni_aio_cancel_fn a_cancel_fn;
+ void * a_cancel_arg;
+ nni_list_node a_prov_node; // Linkage on provider list.
+ void * a_prov_extra[2]; // Extra data used by provider
// Expire node.
nni_list_node a_expire_node;