From 8b4ddf10e71e1c8fabd33c72b282f7da65ff682f Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 14 七月 2020 15:59:44 +0800 Subject: [PATCH] commit --- queue/include/lock_free_queue.h | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/queue/include/lock_free_queue.h b/queue/include/lock_free_queue.h index b332bc6..d33424e 100644 --- a/queue/include/lock_free_queue.h +++ b/queue/include/lock_free_queue.h @@ -3,7 +3,7 @@ #include <usg_common.h> #include <assert.h> // assert() -#include "mm.h" +#include "mem_pool.h" #include "sem_util.h" #include "logger_factory.h" @@ -13,7 +13,7 @@ // define this macro if calls to "size" must return the real size of the // queue. If it is undefined that function will try to take a snapshot of // the queue, but returned value might be bogus -#define _WITH_LOCK_FREE_Q_KEEP_REAL_SIZE + // forward declarations for default template values // @@ -253,7 +253,8 @@ bool LockFreeQueue<ELEM_T, Q_TYPE>::pop(ELEM_T &a_data) { if (SemUtil::dec(items) == -1) { - err_exit(errno, "remove"); + err_msg(errno, "LockFreeQueue pop"); + return false; } if (m_qImpl.pop(a_data)) { @@ -272,8 +273,10 @@ if (SemUtil::dec_nowait(items) == -1) { if (errno == EAGAIN) return false; - else - err_exit(errno, "remove_nowait"); + else { + err_msg(errno, "LockFreeQueue pop_nowait"); + return false; + } } if (m_qImpl.pop(a_data)) { @@ -293,8 +296,10 @@ if (SemUtil::dec_timeout(items, timeout) == -1) { if (errno == EAGAIN) return false; - else - err_exit(errno, "remove_timeout"); + else { + err_msg(errno, "LockFreeQueue pop_timeout"); + return false; + } } if (m_qImpl.pop(a_data)) { @@ -316,14 +321,14 @@ typename ELEM_T, template <typename T> class Q_TYPE> void * LockFreeQueue<ELEM_T, Q_TYPE>::operator new(size_t size){ - return mm_malloc(size); + return mem_pool_malloc(size); } template < typename ELEM_T, template <typename T> class Q_TYPE> void LockFreeQueue<ELEM_T, Q_TYPE>::operator delete(void *p) { - return mm_free(p); + return mem_pool_free(p); } // include implementation files -- Gitblit v1.8.0