2#ifndef _KURLYK_EVENT_QUEUE_HPP_INCLUDED
3#define _KURLYK_EVENT_QUEUE_HPP_INCLUDED
10#include <condition_variable>
22 std::lock_guard<std::mutex> lock(
m_mutex);
30 std::lock_guard<std::mutex> lock(
m_mutex);
38 std::unique_lock<std::mutex> lock(
m_mutex);
40 T
event = std::move(
m_events.front());
48 std::lock_guard<std::mutex> lock(
m_mutex);
A thread-safe event queue that supports blocking and non-blocking event retrieval.
T pop_event()
Removes and returns an event from the queue (blocks if the queue is empty).
void push_event(T &&event)
Adds an event to the queue using move semantics.
void push_event(const T &event)
Adds a copy of an event to the queue and notifies any waiting threads.
std::queue< T > m_events
Queue to store events.
bool has_events() const
Checks if there are events in the queue.
std::condition_variable m_cond_var
Condition variable for blocking until events are available.
std::mutex m_mutex
Mutex to protect queue access.