summaryrefslogtreecommitdiff
path: root/src/core/msgqueue.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-09 13:01:22 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-09 13:01:22 -0800
commit848f8f62d7c6d6ea061dd0513a6bffc1ef358ff3 (patch)
tree24a31a22803355a4a85293cb35c066b32c651b58 /src/core/msgqueue.h
parent02231e715c4cb67d3394ee363a758f6b3e6b53b8 (diff)
downloadnng-848f8f62d7c6d6ea061dd0513a6bffc1ef358ff3.tar.gz
nng-848f8f62d7c6d6ea061dd0513a6bffc1ef358ff3.tar.bz2
nng-848f8f62d7c6d6ea061dd0513a6bffc1ef358ff3.zip
Add survey test (and fix survey pattern).
As part of this, we've added a way to unblock callers in a message queue with an error, even without a signal channel. This was necessary to interrupt blockers upon survey timeout. They will get NNG_ETIMEDOUT, but afterwards callers get NNG_ESTATE.
Diffstat (limited to 'src/core/msgqueue.h')
-rw-r--r--src/core/msgqueue.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/msgqueue.h b/src/core/msgqueue.h
index 09d7fa0c..450c55a4 100644
--- a/src/core/msgqueue.h
+++ b/src/core/msgqueue.h
@@ -87,6 +87,24 @@ extern int nni_msgq_get_sig(nni_msgq *, nni_msg **, nni_signal *);
// It modifies the turnstile's value under the lock to a non-zero value.
extern void nni_msgq_signal(nni_msgq *, nni_signal *);
+// nni_msgq_set_error sets an error condition on the message queue,
+// which causes all current and future readers/writes to return the
+// given error condition (if non-zero). Threads waiting to put or get
+// are woken as well, if non-zero. If zero, then any present error
+// condition is cleared, and waiters are not woken (there shouldn't be
+// any waiters unless it was already zero.)
+extern void nni_msgq_set_error(nni_msgq *, int);
+
+// nni_msgq_set_put_error sets an error condition on the put side of the
+// message queue, and for that side behaves like nni_msgq_set_error.
+// Readers (nni_msgq_get*) are unaffected.
+extern void nni_msgq_set_put_error(nni_msgq *, int);
+
+// nni_msgq_set_get_error sets an error condition on the get side of the
+// message queue, and for that side behaves like nni_msgq_set_error.
+// Readers (nni_msgq_put*) are unaffected.
+extern void nni_msgq_set_get_error(nni_msgq *, int);
+
// nni_msgq_close closes the queue. After this all operates on the
// message queue will return NNG_ECLOSED. Messages inside the queue
// are freed. Unlike closing a go channel, this operation is idempotent.