MythTV  master
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes | List of all members
TaskQueue Class Reference

#include <taskqueue.h>

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

Public Member Functions

 ~TaskQueue () override
 
void RequestTerminate ()
 
void Clear ()
 
void AddTask (std::chrono::milliseconds msec, Task *pTask)
 Add a task to run in the future. More...
 
void AddTask (Task *pTask)
 Add a task to run now. More...
 
TaskGetNextExpiredTask (TaskTime tt, std::chrono::milliseconds nWithinMilliSecs=50ms)
 
- 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 ()
 
 MThread (const MThread &)=delete
 
MThreadoperator= (const MThread &)=delete
 
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 p=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 (std::chrono::milliseconds time=std::chrono::milliseconds::max())
 Wait for the MThread to exit, with a maximum timeout. More...
 

Static Public Member Functions

static TaskQueueInstance ()
 
static void Shutdown ()
 
- Static Public Member Functions inherited from MThread
static void ThreadSetup (const QString &name)
 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)
 

Protected Member Functions

bool IsTermRequested ()
 
void run () override
 Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead. More...
 
- Protected Member Functions inherited from MThread
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread. More...
 

Protected Attributes

TaskMap m_mapTasks
 
QMutex m_mutex
 
bool m_bTermRequested {false}
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prologExecuted {true}
 
bool m_epilogExecuted {true}
 

Private Member Functions

 TaskQueue ()
 
void AddTaskAbsolute (TaskTime tt, Task *pTask)
 Add a task to run at a specific time. More...
 

Static Private Attributes

static TaskQueueg_pTaskQueue = nullptr
 

Additional Inherited Members

- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void usleep (std::chrono::microseconds time)
 
template<typename R , typename P >
static std::enable_if_t< std::chrono::treat_as_floating_point< R >::value, void > usleep (std::chrono::duration< R, P > time)
 

Detailed Description

Definition at line 82 of file taskqueue.h.

Constructor & Destructor Documentation

◆ TaskQueue()

TaskQueue::TaskQueue ( )
private

Definition at line 80 of file taskqueue.cpp.

Referenced by Instance().

◆ ~TaskQueue()

TaskQueue::~TaskQueue ( )
override

Definition at line 93 of file taskqueue.cpp.

Member Function Documentation

◆ IsTermRequested()

bool TaskQueue::IsTermRequested ( )
protected

◆ run()

void TaskQueue::run ( )
overrideprotectedvirtual

Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.

Note
If you override this method you must call RunProlog before you do any work and RunEpilog before you exit the run method.

Reimplemented from MThread.

Definition at line 111 of file taskqueue.cpp.

◆ Instance()

TaskQueue * TaskQueue::Instance ( )
static

◆ Shutdown()

void TaskQueue::Shutdown ( )
static

Definition at line 69 of file taskqueue.cpp.

Referenced by MythContext::~MythContext().

◆ RequestTerminate()

void TaskQueue::RequestTerminate ( )

Definition at line 102 of file taskqueue.cpp.

Referenced by cleanup().

◆ Clear()

void TaskQueue::Clear ( )

Definition at line 151 of file taskqueue.cpp.

Referenced by ~TaskQueue().

◆ AddTask() [1/2]

void TaskQueue::AddTask ( std::chrono::milliseconds  msec,
Task pTask 
)

Add a task to run in the future.

Parameters
msecThe number of milliseconds in the future to run this task
pTaskA pointer to the task.

Definition at line 172 of file taskqueue.cpp.

Referenced by SSDP::EnableNotifications(), UPnpNotifyTask::Execute(), Eventing::NotifySubscriber(), SSDP::ProcessSearchRequest(), and SSDPCache::SSDPCache().

◆ AddTask() [2/2]

void TaskQueue::AddTask ( Task pTask)

Add a task to run now.

Parameters
pTaskA pointer to the task.

Definition at line 201 of file taskqueue.cpp.

◆ GetNextExpiredTask()

Task * TaskQueue::GetNextExpiredTask ( TaskTime  tt,
std::chrono::milliseconds  nWithinMilliSecs = 50ms 
)

Definition at line 216 of file taskqueue.cpp.

Referenced by run().

◆ AddTaskAbsolute()

void TaskQueue::AddTaskAbsolute ( TaskTime  ttKey,
Task pTask 
)
private

Add a task to run at a specific time.

Parameters
msecThe time when this task should run
pTaskA pointer to the task.

Definition at line 185 of file taskqueue.cpp.

Referenced by AddTask().

Member Data Documentation

◆ g_pTaskQueue

TaskQueue * TaskQueue::g_pTaskQueue = nullptr
staticprivate

Definition at line 87 of file taskqueue.h.

Referenced by Instance(), and Shutdown().

◆ m_mapTasks

TaskMap TaskQueue::m_mapTasks
protected

Definition at line 91 of file taskqueue.h.

Referenced by AddTaskAbsolute(), Clear(), and GetNextExpiredTask().

◆ m_mutex

QMutex TaskQueue::m_mutex
protected

Definition at line 92 of file taskqueue.h.

Referenced by AddTaskAbsolute(), Clear(), and GetNextExpiredTask().

◆ m_bTermRequested

bool TaskQueue::m_bTermRequested {false}
protected

Definition at line 93 of file taskqueue.h.

Referenced by RequestTerminate(), run(), and ~TaskQueue().


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