X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmisc.cpp;h=ababdbc1d7df8d4276e0de838a0ef34e5faf3071;hp=1a092c612fd2abc084acc27366d6644622c0d5d3;hb=92e759a676b5f2886160fc8f43744f137a0a19b1;hpb=3df2c01b5769c7ae996fb5b992c06e4a5428ad35 diff --git a/src/misc.cpp b/src/misc.cpp index 1a092c61..ababdbc1 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -146,6 +146,23 @@ public: }; +/// Used to serialize access to std::cout to avoid multiple threads to write at +/// the same time. + +std::ostream& operator<<(std::ostream& os, SyncCout sc) { + + static Mutex m; + + if (sc == io_lock) + m.lock(); + + if (sc == io_unlock) + m.unlock(); + + return os; +} + + /// Trampoline helper to avoid moving Logger to misc.h void start_logger(bool b) { Logger::start(b); }