global mutex stdout stderr sinks

This commit is contained in:
gabime
2018-04-16 01:07:22 +03:00
parent c50ba69689
commit 9bffa921ae
2 changed files with 79 additions and 37 deletions

View File

@@ -17,6 +17,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <thread>
#include <mutex>
#ifdef _WIN32
@@ -474,6 +475,19 @@ inline bool in_terminal(FILE *file)
return isatty(fileno(file)) != 0;
#endif
}
// stdout/stderr global mutexes
inline std::mutex& stdout_mutex()
{
static std::mutex &mutex = std::mutex{};
return mutex;
}
inline std::mutex& stderr_mutex()
{
static std::mutex &mutex = std::mutex{};
return mutex;
}
} // namespace os
} // namespace details
} // namespace spdlog