Report lock
This commit is contained in:
parent
0f91d677e3
commit
85e0254629
|
|
@ -19,6 +19,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <mutex>
|
||||||
#include "DisallowCopyAssign.hh"
|
#include "DisallowCopyAssign.hh"
|
||||||
|
|
||||||
struct Tcl_Interp;
|
struct Tcl_Interp;
|
||||||
|
|
@ -113,6 +114,7 @@ protected:
|
||||||
char *buffer_;
|
char *buffer_;
|
||||||
// Length of string in buffer.
|
// Length of string in buffer.
|
||||||
size_t buffer_length_;
|
size_t buffer_length_;
|
||||||
|
std::mutex buffer_lock_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(Report);
|
DISALLOW_COPY_AND_ASSIGN(Report);
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ Report::print(const string &str)
|
||||||
void
|
void
|
||||||
Report::vprint(const char *fmt, va_list args)
|
Report::vprint(const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(buffer_lock_);
|
||||||
printToBuffer(fmt, args);
|
printToBuffer(fmt, args);
|
||||||
printString(buffer_, buffer_length_);
|
printString(buffer_, buffer_length_);
|
||||||
}
|
}
|
||||||
|
|
@ -121,6 +122,7 @@ Report::printError(const char *buffer, size_t length)
|
||||||
void
|
void
|
||||||
Report::vprintError(const char *fmt, va_list args)
|
Report::vprintError(const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(buffer_lock_);
|
||||||
printToBuffer(fmt, args);
|
printToBuffer(fmt, args);
|
||||||
printError(buffer_, buffer_length_);
|
printError(buffer_, buffer_length_);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue