| | |
| | | int items; |
| | | |
| | | public: |
| | | // int mutex; |
| | | LockFreeQueue(size_t qsize = LOCK_FREE_Q_DEFAULT_SIZE); |
| | | |
| | | /// @brief destructor of the class. |
| | |
| | | // std::cout << "LockFreeQueue init reference=" << reference << std::endl; |
| | | slots = SemUtil::get(IPC_PRIVATE, qsize); |
| | | items = SemUtil::get(IPC_PRIVATE, 0); |
| | | // mutex = SemUtil::get(IPC_PRIVATE, 1); |
| | | } |
| | | |
| | | template < |
| | |
| | | bool LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::push(const ELEM_T &a_data) |
| | | { |
| | | if (SemUtil::dec(slots) == -1) { |
| | | err_exit(errno, "push"); |
| | | err_msg(errno, "LockFreeQueue push"); |
| | | return false; |
| | | } |
| | | |
| | | if ( m_qImpl.push(a_data) ) { |
| | |
| | | if (SemUtil::dec_nowait(slots) == -1) { |
| | | if (errno == EAGAIN) |
| | | return false; |
| | | else |
| | | err_exit(errno, "push_nowait"); |
| | | else { |
| | | err_msg(errno, "LockFreeQueue push_nowait"); |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | |
| | | if ( m_qImpl.push(a_data)) { |
| | |
| | | if (SemUtil::dec_timeout(slots, timeout) == -1) { |
| | | if (errno == EAGAIN) |
| | | return false; |
| | | else |
| | | err_exit(errno, "push_timeout"); |
| | | else { |
| | | err_msg(errno, "LockFreeQueue push_timeout"); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | if (m_qImpl.push(a_data)){ |