Go to the documentation of this file.
82 LOG(VB_UPNP, LOG_INFO,
"Starting TaskQueue Thread...");
86 LOG(VB_UPNP, LOG_INFO,
"TaskQueue Thread Started.");
115 LOG(VB_UPNP, LOG_INFO,
"TaskQueue Thread Running.");
123 auto ttNow = nowAsDuration<std::chrono::microseconds>();
126 if (pTask !=
nullptr)
135 LOG(VB_GENERAL, LOG_ERR,
"Call to Execute threw an exception.");
157 if (task.second !=
nullptr)
158 task.second->DecrRef();
174 auto tt = nowAsDuration<std::chrono::microseconds>() + msec;
187 if (pTask !=
nullptr)
191 m_mapTasks.insert( TaskMap::value_type( ttKey, pTask ));
204 if (pTask !=
nullptr)
206 auto tt = nowAsDuration<std::chrono::microseconds>();
218 Task *pTask =
nullptr;
220 tt += nWithinMilliSecs ;
233 pTask = (*it).second;
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
std::chrono::microseconds TaskTime
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
virtual void Execute(TaskQueue *pQueue)=0
Task * GetNextExpiredTask(TaskTime tt, std::chrono::milliseconds nWithinMilliSecs=50ms)
static void usleep(std::chrono::microseconds time)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
static QMutex g_pTaskQueueCreationLock
static TaskQueue * Instance()
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
static TaskQueue * g_pTaskQueue
void AddTaskAbsolute(TaskTime tt, Task *pTask)
Add a task to run at a specific time.
Task(const QString &debugName)
void AddTask(std::chrono::milliseconds msec, Task *pTask)
Add a task to run in the future.
This is a wrapper around QThread that does several additional things.
virtual int IncrRef(void)
Increments reference count.
General purpose reference counter.