CThreadMsgStream Class Reference

This class is used to handle syncronizized output of logging output in a multi-threaded environment. More...

#include <mia/core/threadedmsg.hh>

Inherits ostream.

Public Member Functions

 CThreadMsgStream ()
 
 ~CThreadMsgStream ()
 

Static Public Member Functions

template<typename OS >
static void set_master_stream (OS &master)
 

Friends

template<typename OS , typename placeholder >
struct __dispatch_set_master_stream
 

Detailed Description

This class is used to handle syncronizized output of logging output in a multi-threaded environment.

This class is used to syncronize the output of the logging stream cverb and its helper functions cvmsg(), cvdebug(), cverror(), cvwarning() ...

To use it, just declare a variable of type CThreadMsgStream at the beginning of the threaded function. Output is only written to the master output stream if a newline is sent or explicit syncronization via flush() is requested.

Note, that a CThreadMsgStream itself can not serve as master stream since it would deadlock.

Definition at line 44 of file threadedmsg.hh.

Constructor & Destructor Documentation

◆ CThreadMsgStream()

CThreadMsgStream::CThreadMsgStream ( )

Constructor. This constructor sets the thread-local output of the vstream backend to itself and saves to old output.

◆ ~CThreadMsgStream()

CThreadMsgStream::~CThreadMsgStream ( )

Destructor. This destructor flushes the output and then resets the thread-local vstream backend to the original output.

Member Function Documentation

◆ set_master_stream()

template<typename OS >
void CThreadMsgStream::set_master_stream ( OS &  master)
static

Set the master output stream. The default is std::cerr.

Parameters
masterthe new master output stream;
Remarks
if the new master is of type CThreadMsgStream a deadlock is certain.

Definition at line 108 of file threadedmsg.hh.

References NS_MIA_END.

Friends And Related Function Documentation

◆ __dispatch_set_master_stream

template<typename OS , typename placeholder >
friend struct __dispatch_set_master_stream
friend

Definition at line 66 of file threadedmsg.hh.


The documentation for this class was generated from the following file: