From a4d18d6ab3216ce1bf8052f0fdc4ea34bc6385e8 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期三, 20 一月 2021 19:39:17 +0800
Subject: [PATCH] update

---
 src/queue/shm_queue.h |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/queue/shm_queue.h b/src/queue/shm_queue.h
index 8a23da1..7d98eaa 100644
--- a/src/queue/shm_queue.h
+++ b/src/queue/shm_queue.h
@@ -1,3 +1,7 @@
+/**
+ * encapsulate lock_free_queue, populate in userspace
+ */
+
 #ifndef __SHM_QUEUE_H__
 #define __SHM_QUEUE_H__
 
@@ -7,8 +11,7 @@
 #include "sem_util.h"
 #include "shm_allocator.h"
 #include "usg_common.h"
-// default Queue size
-// #define LOCK_FREE_Q_DEFAULT_SIZE 16
+
 
 template <typename ELEM_T> class SHMQueue {
 
@@ -28,13 +31,12 @@
   inline bool full();
   inline bool empty();
 
-  inline bool push(const ELEM_T &a_data);
-  inline bool push_nowait(const ELEM_T &a_data);
-  inline bool push_timeout(const ELEM_T &a_data,
-                           const struct timespec *timeout);
-  inline bool pop(ELEM_T &a_data);
-  inline bool pop_nowait(ELEM_T &a_data);
-  inline bool pop_timeout(ELEM_T &a_data, struct timespec *timeout);
+  inline int push(const ELEM_T &a_data);
+  inline int push_nowait(const ELEM_T &a_data);
+  inline int push_timeout(const ELEM_T &a_data, const struct timespec *timeout);
+  inline int pop(ELEM_T &a_data);
+  inline int pop_nowait(ELEM_T &a_data);
+  inline int pop_timeout(ELEM_T &a_data, struct timespec *timeout);
 
   inline ELEM_T &operator[](unsigned i);
 
@@ -167,23 +169,23 @@
 }
 
 template <typename ELEM_T>
-inline bool SHMQueue<ELEM_T>::push(const ELEM_T &a_data) {
+inline int SHMQueue<ELEM_T>::push(const ELEM_T &a_data) {
   return queue->push(a_data);
 }
 
 template <typename ELEM_T>
-inline bool SHMQueue<ELEM_T>::push_nowait(const ELEM_T &a_data) {
+inline int SHMQueue<ELEM_T>::push_nowait(const ELEM_T &a_data) {
   return queue->push_nowait(a_data);
 }
 
 template <typename ELEM_T>
-inline bool SHMQueue<ELEM_T>::push_timeout(const ELEM_T &a_data,
+inline int SHMQueue<ELEM_T>::push_timeout(const ELEM_T &a_data,
                                            const struct timespec *timeout) {
 
   return queue->push_timeout(a_data, timeout);
 }
 
-template <typename ELEM_T> inline bool SHMQueue<ELEM_T>::pop(ELEM_T &a_data) {
+template <typename ELEM_T> inline int SHMQueue<ELEM_T>::pop(ELEM_T &a_data) {
   // printf("SHMQueue pop before\n");
   int rv = queue->pop(a_data);
   // printf("SHMQueue after before\n");
@@ -191,13 +193,12 @@
 }
 
 template <typename ELEM_T>
-inline bool SHMQueue<ELEM_T>::pop_nowait(ELEM_T &a_data) {
+inline int SHMQueue<ELEM_T>::pop_nowait(ELEM_T &a_data) {
   return queue->pop_nowait(a_data);
 }
 
 template <typename ELEM_T>
-inline bool SHMQueue<ELEM_T>::pop_timeout(ELEM_T &a_data,
-                                          struct timespec *timeout) {
+inline int SHMQueue<ELEM_T>::pop_timeout(ELEM_T &a_data, struct timespec *timeout) {
   return queue->pop_timeout(a_data, timeout);
 }
 

--
Gitblit v1.8.0