wangzhengquan
2020-07-25 8ec1d776751f62c43335d36c3427dc1ab2d84a61
src/queue/include/lock_free_queue.h
@@ -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);      
// printf("==================LockFreeQueue push after\n");
        return true;
    }
    return false;
@@ -244,6 +247,7 @@
bool LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::push_timeout(const ELEM_T &a_data, struct timespec * timeout)
{
    if (SemUtil::dec_timeout(slots, timeout) == -1) {
        if (errno == EAGAIN)
            return false;
@@ -270,6 +274,7 @@
    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;
@@ -277,6 +282,7 @@
    if (m_qImpl.pop(a_data)) {
        SemUtil::inc(slots);      
// printf("==================LockFreeQueue pop after\n");
        return true;
    }
    return false;