17 #ifndef COM_BORA_SOFTWARE__BALAU_CONTAINER__SYNCHRONISED_QUEUE 18 #define COM_BORA_SOFTWARE__BALAU_CONTAINER__SYNCHRONISED_QUEUE 38 public:
void enqueue(T && element)
override {
39 std::lock_guard<std::mutex> lock(mutex);
40 elements.push_back(std::move(element));
49 std::lock_guard<std::mutex> lock(mutex);
51 if (elements.empty()) {
55 T element = std::move(elements.front());
60 public:
bool empty()
const override {
61 std::lock_guard<std::mutex> lock(mutex);
62 return elements.size() == 0;
67 private: std::list<T> elements;
68 private:
mutable std::mutex mutex;
73 #endif // COM_BORA_SOFTWARE__BALAU_CONTAINER__SYNCHRONISED_QUEUE T dequeue() override
Dequeue an object.
Definition: SynchronizedQueue.hpp:48
Base interface for queues.
Definition: Queue.hpp:27
Base interface for queues.
#define ThrowBalauException(ExceptionClass,...)
Throw a Balau style exception, with implicit file and line number, and optional stacktrace.
Definition: BalauException.hpp:45
Various container classes, apart from interprocess containers.
Definition: ArrayBlockingQueue.hpp:25
Balau exceptions for containers.
Thrown when a request is made for an element but no elements are available.
Definition: ContainerExceptions.hpp:46
A queue that uses a mutex to synchronise enqueue and dequeue calls.
Definition: SynchronizedQueue.hpp:37
bool empty() const override
Returns true if the queue is empty.
Definition: SynchronizedQueue.hpp:60
Core includes, typedefs and functions.
void enqueue(T &&element) override
Enqueue an object, moving the supplied element.
Definition: SynchronizedQueue.hpp:38