diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-03-04 02:46:40 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-03-04 02:46:40 -0800 |
| commit | fb6550a242bb1742ec62202a99d0604ee9069795 (patch) | |
| tree | bd235a8ddf6766dc54c3e47b31dbc7a59802d5da /src/core/aio.c | |
| parent | c17a1dd3f5333da59355ecc3f8788a0396a8f72d (diff) | |
| download | nng-fb6550a242bb1742ec62202a99d0604ee9069795.tar.gz nng-fb6550a242bb1742ec62202a99d0604ee9069795.tar.bz2 nng-fb6550a242bb1742ec62202a99d0604ee9069795.zip | |
Pipeline protocol now entirely callback driven.
Diffstat (limited to 'src/core/aio.c')
| -rw-r--r-- | src/core/aio.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/aio.c b/src/core/aio.c index a3f4fb28..ffc5ac06 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -12,20 +12,29 @@ #define NNI_AIO_WAKE (1<<0) -void +int nni_aio_init(nni_aio *aio, nni_cb cb, void *arg) { + int rv; + if (cb == NULL) { cb = (nni_cb) nni_aio_wake; arg = aio; } memset(aio, 0, sizeof (*aio)); - nni_mtx_init(&aio->a_lk); - nni_cv_init(&aio->a_cv, &aio->a_lk); + if ((rv = nni_mtx_init(&aio->a_lk)) != 0) { + return (rv); + } + if ((rv = nni_cv_init(&aio->a_cv, &aio->a_lk)) != 0) { + nni_mtx_fini(&aio->a_lk); + return (rv); + } aio->a_cb = cb; aio->a_cbarg = arg; aio->a_expire = NNI_TIME_NEVER; nni_taskq_ent_init(&aio->a_tqe, cb, arg); + + return (0); } |
