From 6c5289ee6886ffa78e5cc95a5b6947145d2001e1 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期一, 25 一月 2021 14:15:39 +0800 Subject: [PATCH] update --- src/queue/shm_queue.h | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/queue/shm_queue.h b/src/queue/shm_queue.h index 8a23da1..ed7acf0 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,37 +169,36 @@ } 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) { - // printf("SHMQueue pop before\n"); +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"); + printf("SHMQueue after before\n"); return rv; } template <typename ELEM_T> -inline bool SHMQueue<ELEM_T>::pop_nowait(ELEM_T &a_data) { - return queue->pop_nowait(a_data); +inline int SHMQueue<ELEM_T>::pop_nowait(ELEM_T &a_data) { + int rv = 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