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

Manages registered HouseKeeperTasks and queues tasks for operation. More...

#include <housekeeper.h>

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

Public Slots

void Run (void)
 

Public Member Functions

 HouseKeeper (void)
 
 ~HouseKeeper ()
 
void RegisterTask (HouseKeeperTask *task)
 
void Start (void)
 
void StartThread (void)
 Wake the primary run thread, or create a new one. More...
 
HouseKeeperTaskGetQueuedTask (void)
 
void customEvent (QEvent *e) override
 

Private Attributes

QTimer * m_timer
 
QQueue< HouseKeeperTask * > m_taskQueue
 
QMutex m_queueLock
 
QMap< QString, HouseKeeperTask * > m_taskMap
 
QMutex m_mapLock
 
QList< HouseKeepingThread * > m_threadList
 
QMutex m_threadLock
 

Detailed Description

Manages registered HouseKeeperTasks and queues tasks for operation.

This class operates threadless, in the main application event loop. Its only role is to check whether tasks are ready to be run, so computation in those methods should be kept to a minimum to not stall the event loop. Tasks ready to run are placed into a queue for the run thread to run.

To use, one instance of this should be created at application init. All housekeeping tasks should be registered using RegisterTask(), and then the housekeeper started using Start. Tasks can be added at a later time, however special startup behavior will not be honored. Tasks cannot be removed from the housekeeper once added.

Definition at line 148 of file housekeeper.h.

Constructor & Destructor Documentation

◆ HouseKeeper()

HouseKeeper::HouseKeeper ( void  )

Definition at line 565 of file housekeeper.cpp.

◆ ~HouseKeeper()

HouseKeeper::~HouseKeeper ( void  )

Definition at line 573 of file housekeeper.cpp.

Member Function Documentation

◆ RegisterTask()

void HouseKeeper::RegisterTask ( HouseKeeperTask task)

Definition at line 628 of file housekeeper.cpp.

Referenced by main(), and run_backend().

◆ Start()

void HouseKeeper::Start ( void  )

Definition at line 662 of file housekeeper.cpp.

Referenced by main(), and run_backend().

◆ StartThread()

void HouseKeeper::StartThread ( void  )

Wake the primary run thread, or create a new one.

The HouseKeeper maintains one primary thread, but allows for multiple to allow task processing to continue should one long-running thread stall.

The HouseKeeper scans to queue tasks once a minute. If any tasks are in the queue at the end of the scan, this method will be run. If the primary thread is still in use from the previous scan, it will be marked for destruction and a replacement thread will be started to pick up the remainder of the queue. The in-progress thread will terminate itself once its current task has finished, and will be eventually cleaned up by this method.

Definition at line 785 of file housekeeper.cpp.

Referenced by Run().

◆ GetQueuedTask()

HouseKeeperTask * HouseKeeper::GetQueuedTask ( void  )

Definition at line 647 of file housekeeper.cpp.

Referenced by HouseKeepingThread::run().

◆ customEvent()

void HouseKeeper::customEvent ( QEvent *  e)
override

Definition at line 822 of file housekeeper.cpp.

◆ Run

void HouseKeeper::Run ( void  )
slot

Definition at line 720 of file housekeeper.cpp.

Referenced by HouseKeeper().

Member Data Documentation

◆ m_timer

QTimer* HouseKeeper::m_timer
private

Definition at line 167 of file housekeeper.h.

Referenced by HouseKeeper(), Start(), and ~HouseKeeper().

◆ m_taskQueue

QQueue<HouseKeeperTask*> HouseKeeper::m_taskQueue
private

Definition at line 169 of file housekeeper.h.

Referenced by GetQueuedTask(), Run(), Start(), and ~HouseKeeper().

◆ m_queueLock

QMutex HouseKeeper::m_queueLock
private

Definition at line 170 of file housekeeper.h.

Referenced by GetQueuedTask(), Run(), Start(), and ~HouseKeeper().

◆ m_taskMap

QMap<QString, HouseKeeperTask*> HouseKeeper::m_taskMap
private

Definition at line 172 of file housekeeper.h.

Referenced by customEvent(), RegisterTask(), Run(), Start(), and ~HouseKeeper().

◆ m_mapLock

QMutex HouseKeeper::m_mapLock
private

Definition at line 173 of file housekeeper.h.

Referenced by customEvent(), RegisterTask(), Run(), Start(), and ~HouseKeeper().

◆ m_threadList

QList<HouseKeepingThread*> HouseKeeper::m_threadList
private

Definition at line 175 of file housekeeper.h.

Referenced by Run(), StartThread(), and ~HouseKeeper().

◆ m_threadLock

QMutex HouseKeeper::m_threadLock
private

Definition at line 176 of file housekeeper.h.

Referenced by Run(), StartThread(), and ~HouseKeeper().


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