From 66e36f251a61c8b6722a90ecfb195e28c87dd99a Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 28 七月 2020 17:52:57 +0800 Subject: [PATCH] dgram_mod_force_bind 注解 --- src/queue/include/lock_free_queue.h | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/queue/include/lock_free_queue.h b/src/queue/include/lock_free_queue.h index 0b6c42f..25a3392 100644 --- a/src/queue/include/lock_free_queue.h +++ b/src/queue/include/lock_free_queue.h @@ -117,7 +117,7 @@ /// @return true if the element was inserted in the queue. False if the queue was full bool push(const ELEM_T &a_data); bool push_nowait(const ELEM_T &a_data); - bool push_timeout(const ELEM_T &a_data, struct timespec * timeout); + bool push_timeout(const ELEM_T &a_data, const struct timespec * timeout); /// @brief pop the element at the head of the queue /// @param a reference where the element in the head of the queue will be saved to @@ -200,13 +200,16 @@ template <typename T, typename AT> class Q_TYPE> bool LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::push(const ELEM_T &a_data) { +// printf("==================LockFreeQueue push before\n"); if (SemUtil::dec(slots) == -1) { err_msg(errno, "LockFreeQueue push"); return false; } if ( m_qImpl.push(a_data) ) { - SemUtil::inc(items); + + SemUtil::inc(items); +// printf("==================LockFreeQueue push after\n"); return true; } return false; @@ -241,8 +244,9 @@ typename ELEM_T, typename Allocator, template <typename T, typename AT> class Q_TYPE> -bool LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::push_timeout(const ELEM_T &a_data, struct timespec * timeout) +bool LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::push_timeout(const ELEM_T &a_data, const struct timespec * timeout) { + if (SemUtil::dec_timeout(slots, timeout) == -1) { if (errno == EAGAIN) @@ -270,13 +274,15 @@ template <typename T, typename AT> class Q_TYPE> bool LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::pop(ELEM_T &a_data) { +// printf("==================LockFreeQueue pop before\n"); if (SemUtil::dec(items) == -1) { err_msg(errno, "LockFreeQueue pop"); return false; } if (m_qImpl.pop(a_data)) { - SemUtil::inc(slots); + SemUtil::inc(slots); +// printf("==================LockFreeQueue pop after\n"); return true; } return false; -- Gitblit v1.8.0