1#ifndef CONCURRENT_QUEUE_H
2#define CONCURRENT_QUEUE_H
22 std::atomic_size_t mSize;
44 std::unique_lock<std::mutex> _lock(mMutex, std::defer_lock);
47 mQueue.emplace(std::move(element));
64 std::unique_lock<std::mutex> _lock(mMutex, std::defer_lock);
67 mQueue.emplace(element);
83 std::unique_lock<std::mutex> _lock(mMutex, std::defer_lock);
86 element = std::move(mQueue.front());
Thread-safe wrapper around STL queue using locking mechanism.
Definition: concurrent_queue.h:18
bool TryEnqueue(const T &element)
Try to insert an element to the queue via copying.
Definition: concurrent_queue.h:62
bool TryDequeue(T &element)
Try to peek an element from the queue by removing it.
Definition: concurrent_queue.h:81
bool TryEnqueue(T &&element)
Try to insert an element to the queue via moving.
Definition: concurrent_queue.h:42
bool Empty() const noexcept
Indicate whether the queue is empty or not.
Definition: concurrent_queue.h:33