May 2018
Intermediate to advanced
328 pages
8h 15m
English
Although C++ does not have the concept of a console and uses streams to perform input and output operations on sequential media such as files, the std::cout and std::wcout global objects control the output to a stream buffer associated with the C output stream stdout. These global stream objects cannot be safely accessed from different threads. Should you need that, you must synchronize the access to them. That is exactly the purpose of the requested component for this problem.
The logger class, shown as follows, uses an std::mutex to synchronize access to the std::cout object in the log() method. The class is implemented as a thread-safe singleton. The static method instance() returns a reference to ...
Read now
Unlock full access