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);
T * get_lastest_purge_old()
Skip all old messages in the queue and directly return the last one (the most recent, at the bottom of the queue), or nullptr if there is no message.
CThreadSafeQueue()
Default ctor.
std::queue< T * > m_msgs
The queue of messages.
std::mutex m_csQueue
The critical section.
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.
A thread-safe template queue for object passing between threads; for a template argument of T...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void clear()
Clear the queue of messages, freeing memory as required.
virtual ~CThreadSafeQueue()
bool empty() const
Return true if there are no messages.