From 5db7f0f969fb05cb0783acd187857b7b06b09b8b Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 21 Dec 2016 00:38:26 -0800 Subject: Uncrustify configuration, and shorter copyright banners, plus reformat code with uncrustify. (Minor adjustments.) No more arguments! --- src/core/msgqueue.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'src/core/msgqueue.c') diff --git a/src/core/msgqueue.c b/src/core/msgqueue.c index 372d2c08..6b208e70 100644 --- a/src/core/msgqueue.c +++ b/src/core/msgqueue.c @@ -1,23 +1,10 @@ /* * Copyright 2016 Garrett D'Amore * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * This software 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. */ #include "nng_impl.h" @@ -38,7 +25,7 @@ struct nni_msgqueue { int mq_get; int mq_put; int mq_closed; - nng_msg_t *mq_msgs; + nng_msg_t * mq_msgs; }; int @@ -84,6 +71,7 @@ nni_msgqueue_create(nni_msgqueue_t *mqp, int cap) return (0); } + void nni_msgqueue_destroy(nni_msgqueue_t mq) { @@ -108,6 +96,7 @@ nni_msgqueue_destroy(nni_msgqueue_t mq) nni_free(mq, sizeof (*mq)); } + /* * nni_msgqueue_signal raises a signal on the signal object. This allows a * waiter to be signaled, so that it can be woken e.g. due to a pipe closing. @@ -118,6 +107,7 @@ nni_msgqueue_signal(nni_msgqueue_t mq, int *signal) { nni_mutex_enter(mq->mq_lock); *signal = 1; + /* * We have to wake everyone. */ @@ -126,6 +116,7 @@ nni_msgqueue_signal(nni_msgqueue_t mq, int *signal) nni_mutex_exit(mq->mq_lock); } + int nni_msgqueue_put_sig(nni_msgqueue_t mq, nni_msg_t msg, int tmout, int *signal) { @@ -142,7 +133,7 @@ nni_msgqueue_put_sig(nni_msgqueue_t mq, nni_msg_t msg, int tmout, int *signal) nni_mutex_exit(mq->mq_lock); return (NNG_EAGAIN); } - + if (tmout < 0) { (void) nni_cond_wait(mq->mq_writeable); continue; @@ -185,6 +176,7 @@ nni_msgqueue_put_sig(nni_msgqueue_t mq, nni_msg_t msg, int tmout, int *signal) return (0); } + int nni_msgqueue_get_sig(nni_msgqueue_t mq, nni_msg_t *msgp, int tmout, int *signal) { @@ -201,7 +193,7 @@ nni_msgqueue_get_sig(nni_msgqueue_t mq, nni_msg_t *msgp, int tmout, int *signal) nni_mutex_exit(mq->mq_lock); return (NNG_EAGAIN); } - + if (tmout < 0) { (void) nni_cond_wait(mq->mq_readable); continue; @@ -243,23 +235,27 @@ nni_msgqueue_get_sig(nni_msgqueue_t mq, nni_msg_t *msgp, int tmout, int *signal) } nni_mutex_exit(mq->mq_lock); return (0); - } + int nni_msgqueue_get(nni_msgqueue_t mq, nni_msg_t *msgp, int tmout) { int nosig = 0; + return (nni_msgqueue_get_sig(mq, msgp, tmout, &nosig)); } + int nni_msgqueue_put(nni_msgqueue_t mq, nni_msg_t msg, int tmout) { int nosig = 0; + return (nni_msgqueue_put_sig(mq, msg, tmout, &nosig)); } + void nni_msgqueue_close(nni_msgqueue_t mq) { -- cgit v1.2.3-70-g09d2