diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-02-18 18:38:54 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-02-18 18:38:54 -0800 |
| commit | eb0d439ac82c49b244615fba4226a0351c4efd64 (patch) | |
| tree | acbcfb796088b3b9c572b0b914a35079dc4a5d00 /src/core | |
| parent | 82e058a2abae40760f0f9956cdb9d21f8a512624 (diff) | |
| download | nng-eb0d439ac82c49b244615fba4226a0351c4efd64.tar.gz nng-eb0d439ac82c49b244615fba4226a0351c4efd64.tar.bz2 nng-eb0d439ac82c49b244615fba4226a0351c4efd64.zip | |
We don't need putback on message queues after all.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/msgqueue.c | 39 | ||||
| -rw-r--r-- | src/core/msgqueue.h | 6 |
2 files changed, 0 insertions, 45 deletions
diff --git a/src/core/msgqueue.c b/src/core/msgqueue.c index 09f58a33..b09bb817 100644 --- a/src/core/msgqueue.c +++ b/src/core/msgqueue.c @@ -343,45 +343,6 @@ nni_msgq_put_(nni_msgq *mq, nni_msg *msg, nni_time expire, nni_signal *sig) } -// nni_msgq_putback will attempt to put a single message back -// to the head of the queue. It never blocks. Message queues always -// have room for at least one putback. -int -nni_msgq_putback(nni_msgq *mq, nni_msg *msg) -{ - nni_mtx_lock(&mq->mq_lock); - - // if closed, we don't put more... this check is first! - if (mq->mq_closed) { - nni_mtx_unlock(&mq->mq_lock); - return (NNG_ECLOSED); - } - - // room in the queue? - if (mq->mq_len >= mq->mq_cap) { - nni_mtx_unlock(&mq->mq_lock); - return (NNG_EAGAIN); - } - - // Subtract one from the get index, possibly wrapping. - mq->mq_get--; - if (mq->mq_get == 0) { - mq->mq_get = mq->mq_cap; - } - mq->mq_msgs[mq->mq_get] = msg; - mq->mq_len++; - if (mq->mq_rwait) { - mq->mq_rwait = 0; - nni_cv_wake(&mq->mq_readable); - } - - nni_msgq_kick(mq, NNI_MSGQ_NOTIFY_CANGET); - nni_mtx_unlock(&mq->mq_lock); - - return (0); -} - - static int nni_msgq_get_(nni_msgq *mq, nni_msg **msgp, nni_time expire, nni_signal *sig) { diff --git a/src/core/msgqueue.h b/src/core/msgqueue.h index 41cda53e..7451139d 100644 --- a/src/core/msgqueue.h +++ b/src/core/msgqueue.h @@ -47,12 +47,6 @@ extern int nni_msgq_put(nni_msgq *, nni_msg *); // if there is no room to put the message it simply returns NNG_EAGAIN. extern int nni_msgq_tryput(nni_msgq *, nni_msg *); -// nni_msgq_putback returns a message to the head of the queue. -// This is a non-blocking operation, and it returns NNG_EAGAIN if there -// is no room. There is always at least room for one putback after -// a message is retried with nni_msgq_get. -extern int nni_msgq_putback(nni_msgq *, nni_msg *); - // nni_msgq_get gets the message from the queue. It blocks until a // message is available, or the queue is closed, returning either 0 on // success or NNG_ECLOSED if the queue was closed. If a message is |
