A temporary object that locks an output stream on construction and unlocks it (after optionally writing a newline) on destruction.
More...
template<typename StreamT = std::basic_ostream<char>>
class Thea::LockedOutputStream< StreamT >
A temporary object that locks an output stream on construction and unlocks it (after optionally writing a newline) on destruction.
All objects piped to the object in a single line are written atomically. Useful e.g. for writing log messages to the same file/console from multiple threads.
Example:
LockedOutputStream<>(std::cout).
getStream() <<
"This " <<
" line " <<
" will " <<
" be " <<
" written " <<
" atomically";
- Note
- Currently, all objects of this class share the same lock, regardless of the wrapped stream.
Definition at line 52 of file Log.hpp.