From 9daa04ac3cd2ebe9bc32642ea0ef70a90e29a63c Mon Sep 17 00:00:00 2001 From: Darby Johnston Date: Tue, 10 Dec 2024 10:20:07 -0800 Subject: [PATCH] Add a mutex Signed-off-by: Darby Johnston --- lib/toucan/MessageLog.cpp | 1 + lib/toucan/MessageLog.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/toucan/MessageLog.cpp b/lib/toucan/MessageLog.cpp index 4334138..4995e5f 100644 --- a/lib/toucan/MessageLog.cpp +++ b/lib/toucan/MessageLog.cpp @@ -12,6 +12,7 @@ namespace toucan const std::string& message, MessageLogType type) { + std::unique_lock lock(_mutex); switch (type) { case MessageLogType::Info: diff --git a/lib/toucan/MessageLog.h b/lib/toucan/MessageLog.h index 394f992..3e867f1 100644 --- a/lib/toucan/MessageLog.h +++ b/lib/toucan/MessageLog.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include namespace toucan @@ -24,5 +25,8 @@ namespace toucan const std::string& prefix, const std::string& message, MessageLogType = MessageLogType::Info); + + private: + std::mutex _mutex; }; }