svm: queue sub: Add conditional timed wait
On reviece side svm queue only permits blocking and
non-blocking calls. This patch adds timed wait blocking
functionality which returns either on signal/event or
on given time out.
It also preserves the original behavior, so it will not
hurt client applications which are using svm queue.
Change-Id: Ic10632170330a80afb8bc781d4ccddfe4da2c69a
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/svm/queue.h b/src/svm/queue.h
index dc1fc36..856c172 100644
--- a/src/svm/queue.h
+++ b/src/svm/queue.h
@@ -36,6 +36,24 @@
char data[0];
} svm_queue_t;
+typedef enum
+{
+ /**
+ * blocking call
+ */
+ SVM_Q_WAIT = 0,
+
+ /**
+ * non-blocking call
+ */
+ SVM_Q_NOWAIT,
+
+ /**
+ * blocking call, return on signal or time-out
+ */
+ SVM_Q_TIMEDWAIT,
+} svm_q_conditional_wait_t;
+
svm_queue_t *svm_queue_init (int nels,
int elsize,
int consumer_pid,
@@ -43,7 +61,8 @@
void svm_queue_free (svm_queue_t * q);
int svm_queue_add (svm_queue_t * q, u8 * elem, int nowait);
int svm_queue_add2 (svm_queue_t * q, u8 * elem, u8 * elem2, int nowait);
-int svm_queue_sub (svm_queue_t * q, u8 * elem, int nowait);
+int svm_queue_sub (svm_queue_t * q, u8 * elem, svm_q_conditional_wait_t cond,
+ u32 time);
int svm_queue_sub2 (svm_queue_t * q, u8 * elem);
void svm_queue_lock (svm_queue_t * q);
void svm_queue_unlock (svm_queue_t * q);