39 m_nTaskId(m_nTaskCount++)
78 LOG(VB_UPNP, LOG_INFO,
"Starting TaskQueue Thread...");
82 LOG(VB_UPNP, LOG_INFO,
"TaskQueue Thread Started.");
111 LOG(VB_UPNP, LOG_INFO,
"TaskQueue Thread Running.");
119 auto ttNow = nowAsDuration<std::chrono::microseconds>();
122 if (pTask !=
nullptr)
131 LOG(VB_GENERAL, LOG_ERR,
"Call to Execute threw an exception.");
153 if (task.second !=
nullptr)
154 task.second->DecrRef();
170 auto tt = nowAsDuration<std::chrono::microseconds>() + msec;
183 if (pTask !=
nullptr)
187 m_mapTasks.insert( TaskMap::value_type( ttKey, pTask ));
200 if (pTask !=
nullptr)
202 auto tt = nowAsDuration<std::chrono::microseconds>();
214 Task *pTask =
nullptr;
216 tt += nWithinMilliSecs ;
223 std::chrono::microseconds ttTask = (*it).first;
229 pTask = (*it).second;
This is a wrapper around QThread that does several additional things.
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
static void usleep(std::chrono::microseconds time)
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
General purpose reference counter.
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
virtual int IncrRef(void)
Increments reference count.
void AddTaskAbsolute(std::chrono::microseconds tt, Task *pTask)
Add a task to run at a specific time.
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Task * GetNextExpiredTask(std::chrono::microseconds tt, std::chrono::milliseconds nWithinMilliSecs=50ms)
static TaskQueue * g_pTaskQueue
void AddTask(std::chrono::milliseconds msec, Task *pTask)
Add a task to run in the future.
static TaskQueue * Instance()
virtual void Execute(TaskQueue *pQueue)=0
Task(const QString &debugName)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static QMutex g_pTaskQueueCreationLock