diff options
Diffstat (limited to 'src/core/aio.c')
| -rw-r--r-- | src/core/aio.c | 86 |
1 files changed, 43 insertions, 43 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); |
