Mantid
|
This class implements a threadsafe version of the POCO buffer interface to a Logger's stream object. More...
#include <ThreadSafeLogStream.h>
Public Member Functions | |
void | accumulate (const std::string &message) |
accumulate a message to the thread safe accummulator. More... | |
std::string | flush () |
Returns and flushes the accumulated message. More... | |
int | overflow (char c) |
ThreadSafeLogStreamBuf (Poco::Logger &logger, Poco::Message::Priority priority) | |
Constructor. More... | |
Private Member Functions | |
int | writeToDevice (char c) override |
Overridden from base to write to the device in a thread-safe manner. More... | |
Private Attributes | |
std::map< Poco::Thread::TID, std::string > | m_accumulator |
Store a map of thread indices to accummulators of messages. More... | |
std::map< Poco::Thread::TID, std::string > | m_messages |
Store a map of thread indices to messages. More... | |
std::mutex | m_mutex |
mutex protecting logstream More... | |
This class implements a threadsafe version of the POCO buffer interface to a Logger's stream object.
The buffer uses OpenMP API calls to both protect shared memory from access by multiple threads and updates log messages is such a way that they are not mangled by separate threads.
Definition at line 41 of file ThreadSafeLogStream.h.
ThreadSafeLogStreamBuf::ThreadSafeLogStreamBuf | ( | Poco::Logger & | logger, |
Poco::Message::Priority | priority | ||
) |
Constructor.
Definition at line 25 of file ThreadSafeLogStream.cpp.
void ThreadSafeLogStreamBuf::accumulate | ( | const std::string & | message | ) |
accumulate a message to the thread safe accummulator.
message | :: The log message |
Definition at line 53 of file ThreadSafeLogStream.cpp.
References m_accumulator, and m_mutex.
Referenced by Mantid::Kernel::ThreadSafeLogStream::accumulate().
std::string ThreadSafeLogStreamBuf::flush | ( | ) |
Returns and flushes the accumulated message.
Definition at line 62 of file ThreadSafeLogStream.cpp.
References m_accumulator, and m_mutex.
Referenced by Mantid::Kernel::ThreadSafeLogStream::flush().
int ThreadSafeLogStreamBuf::overflow | ( | char | c | ) |
Definition at line 28 of file ThreadSafeLogStream.cpp.
|
overrideprivate |
Overridden from base to write to the device in a thread-safe manner.
If the character is an EOL character then write the buffered messsage to the chosen device(s).
If not, buffer the character
c | :: The input character |
Definition at line 37 of file ThreadSafeLogStream.cpp.
References m_messages, and m_mutex.
|
private |
Store a map of thread indices to accummulators of messages.
Definition at line 58 of file ThreadSafeLogStream.h.
Referenced by accumulate(), and flush().
|
private |
Store a map of thread indices to messages.
Definition at line 56 of file ThreadSafeLogStream.h.
Referenced by writeToDevice().
|
private |
mutex protecting logstream
Definition at line 60 of file ThreadSafeLogStream.h.
Referenced by accumulate(), flush(), and writeToDevice().