MythTV  master
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DBLoggerThread Class Reference

Thread that manages the queueing of logging inserts for the database. More...

#include <loggingserver.h>

Inheritance diagram for DBLoggerThread:
Inheritance graph
[legend]
Collaboration diagram for DBLoggerThread:
Collaboration graph
[legend]

Public Member Functions

 DBLoggerThread (DatabaseLogger *logger)
 DBLoggerThread constructor. More...
 
 ~DBLoggerThread ()
 DBLoggerThread deconstructor. More...
 
void run (void) override
 Start the thread. More...
 
void stop (void)
 Tell the thread to stop by setting the m_aborted flag. More...
 
bool enqueue (LoggingItem *item)
 Enqueues a LoggingItem onto the queue for the thread to consume. More...
 
bool queueFull (void)
 Indicates when the queue is full. More...
 
- Public Member Functions inherited from MThread
 MThread (const QString &objectName)
 Standard constructor. More...
 
 MThread (const QString &objectName, QRunnable *runnable)
 Use this constructor if you want the default run() method to run the QRunnable's run() method instead of entering the Qt event loop. More...
 
virtual ~MThread ()
 
void RunProlog (void)
 Sets up a thread, call this if you reimplement run(). More...
 
void RunEpilog (void)
 Cleans up a thread's resources, call this if you reimplement run(). More...
 
QThread * qthread (void)
 Returns the thread, this will always return the same pointer no matter how often you restart the thread. More...
 
void setObjectName (const QString &name)
 
QString objectName (void) const
 
void setPriority (QThread::Priority priority)
 
QThread::Priority priority (void) const
 
bool isFinished (void) const
 
bool isRunning (void) const
 
void setStackSize (uint stackSize)
 
uint stackSize (void) const
 
void exit (int retcode=0)
 Use this to exit from the thread if you are using a Qt event loop. More...
 
void start (QThread::Priority=QThread::InheritPriority)
 Tell MThread to start running the thread in the near future. More...
 
void terminate (void)
 Kill a thread unsafely. More...
 
void quit (void)
 calls exit(0) More...
 
bool wait (unsigned long time=ULONG_MAX)
 Wait for the MThread to exit, with a maximum timeout. More...
 

Private Member Functions

 DBLoggerThread (const DBLoggerThread &)=delete
 
DBLoggerThreadoperator= (const DBLoggerThread &)=delete
 

Private Attributes

DatabaseLoggerm_logger {nullptr}
 The associated logger instance. More...
 
QMutex m_queueMutex
 Mutex for protecting the queue. More...
 
QQueue< LoggingItem * > * m_queue {nullptr}
 Queue of LoggingItems to insert. More...
 
QWaitCondition * m_wait {nullptr}
 Wait condition used for waiting for the queue to not be full. More...
 
volatile bool m_aborted {false}
 Used during shutdown to indicate that the thread should stop ASAP. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MThread
static void ThreadSetup (const QString &)
 This is to be called on startup in those few threads that haven't been ported to MThread. More...
 
static void ThreadCleanup (void)
 This is to be called on exit in those few threads that haven't been ported to MThread. More...
 
static void Cleanup (void)
 This will print out all the running threads, call exit(1) on each and then wait up to 5 seconds total for all the threads to exit. More...
 
static void GetAllThreadNames (QStringList &list)
 
static void GetAllRunningThreadNames (QStringList &list)
 
- Static Public Attributes inherited from MThread
static const int kDefaultStartTimeout
 
- Protected Member Functions inherited from MThread
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread. More...
 
- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void sleep (unsigned long time)
 
static void msleep (unsigned long time)
 
static void usleep (unsigned long time)
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prologExecuted {true}
 
bool m_epilogExecuted {true}
 

Detailed Description

Thread that manages the queueing of logging inserts for the database.

The database logging gets throttled if it gets overwhelmed, and also during startup. Having a second queue allows the rest of the logging to remain in sync and to allow for burstiness in the database due to things like scheduler runs.

Definition at line 166 of file loggingserver.h.

Constructor & Destructor Documentation

◆ DBLoggerThread() [1/2]

DBLoggerThread::DBLoggerThread ( DatabaseLogger logger)
explicit

DBLoggerThread constructor.

Parameters
loggerDatabaseLogger instance that this thread belongs to

Definition at line 555 of file loggingserver.cpp.

◆ ~DBLoggerThread()

DBLoggerThread::~DBLoggerThread ( )

DBLoggerThread deconstructor.

Waits for the thread to finish, then Empties what remains in the queue before deleting it.

Definition at line 564 of file loggingserver.cpp.

◆ DBLoggerThread() [2/2]

DBLoggerThread::DBLoggerThread ( const DBLoggerThread )
privatedelete

Member Function Documentation

◆ run()

void DBLoggerThread::run ( void  )
overridevirtual

Start the thread.

Reimplemented from MThread.

Definition at line 579 of file loggingserver.cpp.

◆ stop()

void DBLoggerThread::stop ( void  )

Tell the thread to stop by setting the m_aborted flag.

Definition at line 643 of file loggingserver.cpp.

Referenced by DatabaseLogger::stopDatabaseAccess(), and ~DBLoggerThread().

◆ enqueue()

bool DBLoggerThread::enqueue ( LoggingItem item)

Enqueues a LoggingItem onto the queue for the thread to consume.

Definition at line 650 of file loggingserver.cpp.

Referenced by DatabaseLogger::logmsg().

◆ queueFull()

bool DBLoggerThread::queueFull ( void  )
inline

Indicates when the queue is full.

Returns
true when the queue is full

Definition at line 179 of file loggingserver.h.

Referenced by DatabaseLogger::logmsg().

◆ operator=()

DBLoggerThread& DBLoggerThread::operator= ( const DBLoggerThread )
privatedelete

Member Data Documentation

◆ m_logger

DatabaseLogger* DBLoggerThread::m_logger {nullptr}
private

The associated logger instance.

Definition at line 188 of file loggingserver.h.

Referenced by run().

◆ m_queueMutex

QMutex DBLoggerThread::m_queueMutex
private

Mutex for protecting the queue.

Definition at line 189 of file loggingserver.h.

Referenced by enqueue(), queueFull(), run(), stop(), and ~DBLoggerThread().

◆ m_queue

QQueue<LoggingItem *>* DBLoggerThread::m_queue {nullptr}
private

Queue of LoggingItems to insert.

Definition at line 190 of file loggingserver.h.

Referenced by enqueue(), queueFull(), run(), and ~DBLoggerThread().

◆ m_wait

QWaitCondition* DBLoggerThread::m_wait {nullptr}
private

Wait condition used for waiting for the queue to not be full.

Protected by m_queueMutex

Definition at line 191 of file loggingserver.h.

Referenced by run(), stop(), and ~DBLoggerThread().

◆ m_aborted

volatile bool DBLoggerThread::m_aborted {false}
private

Used during shutdown to indicate that the thread should stop ASAP.

Protected by m_queueMutex

Definition at line 194 of file loggingserver.h.

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


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