| | |
| | | |
| | | #include <usg_common.h> |
| | | #include <assert.h> // assert() |
| | | #include "mm.h" |
| | | #include "mem_pool.h" |
| | | #include "sem_util.h" |
| | | #include "logger_factory.h" |
| | | |
| | |
| | | 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)) { |
| | |
| | | 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)) { |
| | |
| | | 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)) { |
| | |
| | | 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 |