aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-07 16:28:36 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-07 16:28:36 -0700
commit24e24c8ac8d05c1e72ef5d71029d24e8832b49a4 (patch)
treecc65bb2817ff88835ad485fe9de1b1eeb6e5c9cc
parent22d991fda77578dd03c8d477f8427631e6383cee (diff)
downloadnng-24e24c8ac8d05c1e72ef5d71029d24e8832b49a4.tar.gz
nng-24e24c8ac8d05c1e72ef5d71029d24e8832b49a4.tar.bz2
nng-24e24c8ac8d05c1e72ef5d71029d24e8832b49a4.zip
Remove some dead code; msg queue depths are always unsigned.
-rw-r--r--src/core/msgqueue.c38
-rw-r--r--src/core/msgqueue.h11
2 files changed, 6 insertions, 43 deletions
diff --git a/src/core/msgqueue.c b/src/core/msgqueue.c
index 2ebc4927..3972e07a 100644
--- a/src/core/msgqueue.c
+++ b/src/core/msgqueue.c
@@ -36,16 +36,12 @@ struct nni_msgq {
};
int
-nni_msgq_init(nni_msgq **mqp, int cap)
+nni_msgq_init(nni_msgq **mqp, unsigned cap)
{
struct nni_msgq *mq;
int rv;
int alloc;
- if (cap < 0) {
- return (NNG_EINVAL);
- }
-
// We allocate 2 extra cells in the fifo. One to accommodate a
// waiting writer when cap == 0. (We can "briefly" move the message
// through.) This lets us behave the same as unbuffered Go channels.
@@ -375,38 +371,6 @@ nni_msgq_aio_get(nni_msgq *mq, nni_aio *aio)
}
int
-nni_msgq_canput(nni_msgq *mq)
-{
- nni_mtx_lock(&mq->mq_lock);
- if (mq->mq_closed) {
- nni_mtx_unlock(&mq->mq_lock);
- return (0);
- }
- if ((mq->mq_len < mq->mq_cap) || !nni_list_empty(&mq->mq_aio_getq)) {
- nni_mtx_unlock(&mq->mq_lock);
- return (1);
- }
- nni_mtx_unlock(&mq->mq_lock);
- return (0);
-}
-
-int
-nni_msgq_canget(nni_msgq *mq)
-{
- nni_mtx_lock(&mq->mq_lock);
- if (mq->mq_closed) {
- nni_mtx_unlock(&mq->mq_lock);
- return (0);
- }
- if ((mq->mq_len != 0) || !nni_list_empty(&mq->mq_aio_putq)) {
- nni_mtx_unlock(&mq->mq_lock);
- return (1);
- }
- nni_mtx_unlock(&mq->mq_lock);
- return (0);
-}
-
-int
nni_msgq_tryput(nni_msgq *mq, nni_msg *msg)
{
nni_aio *raio;
diff --git a/src/core/msgqueue.h b/src/core/msgqueue.h
index 794ac5cd..fa6b845a 100644
--- a/src/core/msgqueue.h
+++ b/src/core/msgqueue.h
@@ -1,5 +1,6 @@
//
// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2017 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -26,17 +27,15 @@
// or by a specific signal (arranged by the caller).
typedef struct nni_msgq nni_msgq;
-// nni_msgq_init creates a message queue with the given capacity,
-// which must be a positive number. It returns NNG_EINVAL if the capacity
-// is invalid, or NNG_ENOMEM if resources cannot be allocated.
-extern int nni_msgq_init(nni_msgq **, int);
+// nni_msgq_init creates a message queue with the given capacity.
+// (If the capacity is zero, then the queue is unbuffered.)
+// It returns NNG_ENOMEM if resources cannot be allocated.
+extern int nni_msgq_init(nni_msgq **, unsigned);
// nni_msgq_fini destroys a message queue. It will also free any
// messages that may be in the queue.
extern void nni_msgq_fini(nni_msgq *);
-extern int nni_msgq_canget(nni_msgq *);
-extern int nni_msgq_canput(nni_msgq *);
extern void nni_msgq_aio_put(nni_msgq *, nni_aio *);
extern void nni_msgq_aio_get(nni_msgq *, nni_aio *);
extern void nni_msgq_aio_notify_get(nni_msgq *, nni_aio *);