|
MythTV master
|
Manages registered HouseKeeperTasks and queues tasks for operation. More...
#include <libmythbase/housekeeper.h>
Public Slots | |
| void | Run (void) |
Public Member Functions | |
| HouseKeeper (void) | |
| ~HouseKeeper () override | |
| void | RegisterTask (HouseKeeperTask *task) |
| void | Start (void) |
| void | StartThread (void) |
| Wake the primary run thread, or create a new one. More... | |
| HouseKeeperTask * | GetQueuedTask (void) |
| void | customEvent (QEvent *e) override |
Private Attributes | |
| QTimer * | m_timer { nullptr } |
| QQueue< HouseKeeperTask * > | m_taskQueue |
| QMutex | m_queueLock |
| QMap< QString, HouseKeeperTask * > | m_taskMap |
| QMutex | m_mapLock |
| QList< HouseKeepingThread * > | m_threadList |
| QMutex | m_threadLock |
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 149 of file housekeeper.h.
| HouseKeeper::HouseKeeper | ( | void | ) |
Definition at line 581 of file housekeeper.cpp.
|
override |
Definition at line 589 of file housekeeper.cpp.
|
override |
Definition at line 838 of file housekeeper.cpp.
| HouseKeeperTask * HouseKeeper::GetQueuedTask | ( | void | ) |
Definition at line 662 of file housekeeper.cpp.
Referenced by HouseKeepingThread::run().
| void HouseKeeper::RegisterTask | ( | HouseKeeperTask * | task | ) |
Definition at line 643 of file housekeeper.cpp.
Referenced by run_backend().
|
slot |
Definition at line 734 of file housekeeper.cpp.
Referenced by HouseKeeper().
| void HouseKeeper::Start | ( | void | ) |
Definition at line 677 of file housekeeper.cpp.
Referenced by run_backend().
| 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 801 of file housekeeper.cpp.
Referenced by Run().
|
private |
Definition at line 174 of file housekeeper.h.
Referenced by customEvent(), RegisterTask(), Run(), Start(), and ~HouseKeeper().
|
private |
Definition at line 171 of file housekeeper.h.
Referenced by GetQueuedTask(), Run(), Start(), and ~HouseKeeper().
|
private |
Definition at line 173 of file housekeeper.h.
Referenced by customEvent(), RegisterTask(), Run(), Start(), and ~HouseKeeper().
|
private |
Definition at line 170 of file housekeeper.h.
Referenced by GetQueuedTask(), Run(), Start(), and ~HouseKeeper().
|
private |
Definition at line 176 of file housekeeper.h.
Referenced by Run(), StartThread(), and ~HouseKeeper().
|
private |
Definition at line 177 of file housekeeper.h.
Referenced by Run(), StartThread(), and ~HouseKeeper().
|
private |
Definition at line 168 of file housekeeper.h.
Referenced by HouseKeeper(), Start(), and ~HouseKeeper().