MythTV  0.26-pre
Public Member Functions | Private Attributes
LoggerThread Class Reference

The logging thread that consumes the logging queue and dispatches each LoggingItem to each logger instance. More...

#include <logging.h>

Inheritance diagram for LoggerThread:
MThread

List of all members.

Public Member Functions

 LoggerThread ()
 LoggerThread constructor.
 ~LoggerThread ()
 LoggerThread destructor. Triggers the deletion of all loggers.
void run (void)
 Run the logging thread.
void stop (void)
 Stop the thread by setting the abort flag after waiting a second for the queue to be flushed.
bool flush (int timeoutMS=200000)
 Wait for the queue to be flushed (up to a timeout)
void handleItem (LoggingItem *item)
 Handles each LoggingItem, generally by handing it off to the various running logger instances.

Private Attributes

QWaitCondition * m_waitNotEmpty
 Condition variable for waiting for the queue to not be empty Protected by logQueueMutex.
QWaitCondition * m_waitEmpty
 Condition variable for waiting for the queue to be empty Protected by logQueueMutex.
bool aborted
 Flag to abort the thread.

Detailed Description

The logging thread that consumes the logging queue and dispatches each LoggingItem to each logger instance.

Definition at line 116 of file libmythbase/logging.h.


Constructor & Destructor Documentation

LoggerThread constructor.

Enables debugging of thread registration and deregistration if the VERBOSE_THREADS environment variable is set.

Definition at line 775 of file logging.cpp.

LoggerThread destructor. Triggers the deletion of all loggers.

Definition at line 791 of file logging.cpp.


Member Function Documentation

void LoggerThread::run ( void  ) [virtual]

Run the logging thread.

This thread reads from the logging queue, and handles distributing the LoggingItems to each logger instance. The thread will not exit until the logging queue is emptied completely, ensuring that all logging is flushed.

Reimplemented from MThread.

Definition at line 813 of file logging.cpp.

Stop the thread by setting the abort flag after waiting a second for the queue to be flushed.

Definition at line 914 of file logging.cpp.

Referenced by logStop(), and ~LoggerThread().

bool LoggerThread::flush ( int  timeoutMS = 200000)

Wait for the queue to be flushed (up to a timeout)

Parameters:
timeoutMSThe number of ms to wait for the queue to flush
Returns:
true if the queue is empty, false otherwise

Definition at line 925 of file logging.cpp.

Referenced by LogPrintLine(), and stop().

Handles each LoggingItem, generally by handing it off to the various running logger instances.

There is a special case for thread registration and deregistration which are also included in the logging queue to keep the thread names in sync with the log messages.

Parameters:
itemThe LoggingItem to be handled

Definition at line 853 of file logging.cpp.

Referenced by LogPrintLine(), and run().


Member Data Documentation

QWaitCondition* LoggerThread::m_waitNotEmpty [private]

Condition variable for waiting for the queue to not be empty Protected by logQueueMutex.

Definition at line 126 of file libmythbase/logging.h.

Referenced by flush(), run(), stop(), and ~LoggerThread().

QWaitCondition* LoggerThread::m_waitEmpty [private]

Condition variable for waiting for the queue to be empty Protected by logQueueMutex.

Definition at line 129 of file libmythbase/logging.h.

Referenced by flush(), run(), and ~LoggerThread().

Flag to abort the thread.

Protected by logQueueMutex

Definition at line 132 of file libmythbase/logging.h.

Referenced by flush(), run(), and stop().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends