MythTV  master
Classes

Framework for handling frequently run background tasks. More...

Collaboration diagram for HouseKeeper:

Classes

class  HouseKeeperTask
 Definition for a single task to be run by the HouseKeeper. More...
 
class  PeriodicHouseKeeperTask
 Modified HouseKeeperTask for tasks to be run at a regular interval. More...
 
class  DailyHouseKeeperTask
 Modified PeriodicHouseKeeperTask for tasks to be run once daily. More...
 
class  HouseKeepingThread
 Thread used to perform queued HouseKeeper tasks. More...
 
class  HouseKeeper
 Manages registered HouseKeeperTasks and queues tasks for operation. More...
 

Detailed Description

Framework for handling frequently run background tasks.

This utility provides the ability to call maintenance tasks in the background at regular intervals. The basic operation consists of a manager class to store the definitions for the various tasks, the task definitions themselves, and one or more threads to run them in.

The manager does not get its own thread, but rather is called at one minute granularity by a timer and the main application thread. This necessitates that the tasks performed by the manager be kept to a minimum. The manager loops through all task definitions, and checks to see if any are ready to be run. If any are ready, they are copied to the queue, and the run thread is woken up.

The run thread sequentially steps through all tasks in the queue and then goes back to sleep. If one run thread is still active by the time the timer triggers a new pass, the existing thread will be discarded, and a new thread will be started to process remaining tasks in the queue. The old thread will terminate itself once finished with its current task, rather than following through with the next item in the queue, or going into wait. This allows the manager to deal with both time-sensitive tasks and long duration tasks, without any special knowledge of behavior.