Add Clear() to MessageBuffer

This commit is contained in:
WarmUpTill 2024-02-21 20:54:48 +01:00 committed by WarmUpTill
parent 782791b013
commit cf97c1f60b

View File

@ -8,6 +8,7 @@ namespace advss {
template<class T> class MessageBuffer {
public:
bool Empty();
void Clear();
void AppendMessage(const T &);
std::optional<T> ConsumeMessage();
@ -22,6 +23,12 @@ template<class T> inline bool MessageBuffer<T>::Empty()
return _buffer.empty();
}
template<class T> inline void MessageBuffer<T>::Clear()
{
std::lock_guard<std::mutex> lock(_mutex);
_buffer.clear();
}
template<class T> inline void MessageBuffer<T>::AppendMessage(const T &message)
{
std::lock_guard<std::mutex> lock(_mutex);