From 85e02546292eba0e68bf16fafedeb3ca78568827 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Sun, 12 Apr 2020 09:46:30 -0700 Subject: [PATCH] Report lock --- include/sta/Report.hh | 2 ++ util/Report.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/sta/Report.hh b/include/sta/Report.hh index 11fe305c..6dd0ca47 100644 --- a/include/sta/Report.hh +++ b/include/sta/Report.hh @@ -19,6 +19,7 @@ #include #include #include +#include #include "DisallowCopyAssign.hh" struct Tcl_Interp; @@ -113,6 +114,7 @@ protected: char *buffer_; // Length of string in buffer. size_t buffer_length_; + std::mutex buffer_lock_; private: DISALLOW_COPY_AND_ASSIGN(Report); diff --git a/util/Report.cc b/util/Report.cc index 7c1617d5..0d8d07eb 100644 --- a/util/Report.cc +++ b/util/Report.cc @@ -88,6 +88,7 @@ Report::print(const string &str) void Report::vprint(const char *fmt, va_list args) { + std::unique_lock lock(buffer_lock_); printToBuffer(fmt, args); printString(buffer_, buffer_length_); } @@ -121,6 +122,7 @@ Report::printError(const char *buffer, size_t length) void Report::vprintError(const char *fmt, va_list args) { + std::unique_lock lock(buffer_lock_); printToBuffer(fmt, args); printError(buffer_, buffer_length_); }