| | |
| | | template <typename ELEM_T> |
| | | class ArrayLockFreeQueue; |
| | | |
| | | template <typename ELEM_T> |
| | | class LinkedLockFreeQueue; |
| | | |
| | | |
| | | /// @brief Lock-free queue based on a circular array |
| | | /// No allocation of extra memory for the nodes handling is needed, but it has |
| | |
| | | template <typename T> class Q_TYPE = ArrayLockFreeQueue > |
| | | class LockFreeQueue |
| | | { |
| | | |
| | | private: |
| | | int slots; |
| | | int items; |
| | | public: |
| | | public: |
| | | std::atomic_uint reference; |
| | | /// @brief constructor of the class |
| | | LockFreeQueue(size_t qsize = LOCK_FREE_Q_DEFAULT_SIZE); |
| | | |
| | |
| | | LockFreeQueue<ELEM_T, Q_TYPE>(const LockFreeQueue<ELEM_T, Q_TYPE> &a_src); |
| | | }; |
| | | |
| | | |
| | | |
| | | template < |
| | | typename ELEM_T, |
| | | template <typename T> class Q_TYPE> |
| | | LockFreeQueue<ELEM_T, Q_TYPE>::LockFreeQueue(size_t qsize): |
| | | m_qImpl(qsize) |
| | | LockFreeQueue<ELEM_T, Q_TYPE>::LockFreeQueue(size_t qsize): reference(0), m_qImpl(qsize) |
| | | { |
| | | // std::cout << "LockFreeQueue init reference=" << reference << std::endl; |
| | | slots = SemUtil::get(IPC_PRIVATE, qsize); |
| | | items = SemUtil::get(IPC_PRIVATE, 0); |
| | | } |
| | |
| | | template <typename T> class Q_TYPE> |
| | | LockFreeQueue<ELEM_T, Q_TYPE>::~LockFreeQueue() |
| | | { |
| | | std::cerr << "LockFreeQueue desctroy" << std::endl; |
| | | SemUtil::remove(slots); |
| | | SemUtil::remove(items); |
| | | } |