mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 01:27:16 +08:00
Introduce serialization of accesses to std::cout
When many threds concurrently print you need to serialize the access to std::cout to avoid output lines are intermixed with the contents of each thread. This is not strictly needed at the moment because only main thread prints out, although some ad-hoc test could trigger UCI::loop() printing while searching. Anyhow we want to lift this pretty avoidable constrain also as a prerequisite for future work. This patch just introduces the support, next one will enable the serialization. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -65,4 +65,11 @@ private:
|
||||
std::vector<Entry> e;
|
||||
};
|
||||
|
||||
|
||||
enum SyncCout { io_lock, io_unlock };
|
||||
std::ostream& operator<<(std::ostream&, SyncCout);
|
||||
|
||||
#define sync_cout std::cout << io_lock
|
||||
#define sync_endl std::endl << io_unlock
|
||||
|
||||
#endif // !defined(MISC_H_INCLUDED)
|
||||
|
||||
Reference in New Issue
Block a user