Потокобезопасный stl stream
http://www.techrepublic.com/article/use-stl-strea ... plus-plus-thread-safe-logging/
To make writing messages a thread-safe process, follow these five steps:
Create an underlying stream U, to which you want thread-safe access.
Create a stream S with a reference to U.
Make sure each thread has its own stream S.
When writing to the stream S, keep the data internally in a buffer until it's flushed.
When stream S is flushed (the current message ends and a new message starts), it should write its buffer to the underlying stream U in a thread-safe manner, and then stream S should flush its buffer.