9 #ifndef CThreadSafeQueue_H
10 #define CThreadSafeQueue_H
75 std::lock_guard<std::mutex> lock(
m_csQueue);
88 std::lock_guard<std::mutex> lock(
m_csQueue);
98 std::lock_guard<std::mutex> lock(
m_csQueue);
117 std::lock_guard<std::mutex> lock(
m_csQueue);
137 std::lock_guard<std::mutex> lock(
m_csQueue);
144 std::lock_guard<std::mutex> lock(
m_csQueue);
A thread-safe template queue for object passing between threads; for a template argument of T,...
bool empty() const
Return true if there are no messages.
CThreadSafeQueue()
Default ctor.
void clear()
Clear the queue of messages, freeing memory as required.
void push(T *msg)
Insert a new message in the queue - The object must be created with "new", and do not delete is after...
size_t size() const
Return the number of queued messages.
std::queue< T * > m_msgs
The queue of messages.
T * get_lastest_purge_old()
Skip all old messages in the queue and directly return the last one (the most recent,...
T * get()
Retrieve the next message in the queue, or nullptr if there is no message.
virtual ~CThreadSafeQueue()
std::mutex m_csQueue
The critical section.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.