1 #ifndef MARLINMT_CONCURRENCY_QUEUE_h 2 #define MARLINMT_CONCURRENCY_QUEUE_h 1 11 namespace concurrency {
46 std::unique_lock<std::mutex> lock(
_mutex) ;
50 _queue.push( std::move(value) ) ;
61 std::unique_lock<std::mutex> lock(
_mutex) ;
65 value = std::move(
_queue.front()) ;
74 std::unique_lock<std::mutex> lock(
_mutex) ;
82 std::unique_lock<std::mutex> lock(
_mutex) ;
94 std::unique_lock<std::mutex> lock(
_mutex) ;
103 std::unique_lock<std::mutex> lock(
_mutex) ;
111 std::unique_lock<std::mutex> lock(
_mutex) ;
112 while( not
_queue.empty() ) {
121 std::unique_lock<std::mutex> lock(
_mutex) ;
131 std::size_t
_maxSize {std::numeric_limits<std::size_t>::max()} ;
std::mutex _mutex
The synchronization mutex.
std::size_t setMaxSize(std::size_t maxsize)
Set the maximum queue size.
std::size_t _maxSize
The maximum size of the queue.
void clear()
Clear the queue.
constexpr unsigned long long value(const Flag_t &flag)
bool isFull() const
Check whether the queue has reached the maximum allowed size.
Queue & operator=(const Queue &)=delete
std::size_t maxSize() const
Get the maximum queue size.
std::queue< T > _queue
The underlying queue object.
std::size_t freeSlots() const
Get the number of free slots in the queue.
Queue(std::size_t maxsize)
Constructor.
bool push(T &value)
Push a value to the queue.
bool pop(T &value)
Pop and get the front element in the queue.
bool empty() const
Whether the queue is empty.