QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RuntimeScheduler.cc
Go to the documentation of this file.
1#include "RuntimeScheduler.h"
2
3#include <QtCore/QThread>
4
7
8QGC_LOGGING_CATEGORY(RuntimeSchedulerLog, "Utilities.Timing.RuntimeScheduler")
9
10RuntimeScheduler* RuntimeScheduler::orDefault(RuntimeScheduler* scheduler, QObject* owner)
11{
12 return scheduler ? scheduler : new QtRuntimeScheduler(owner);
13}
14
15RuntimeScheduler::RuntimeScheduler(QObject* parent) : QObject(parent)
16{
17 qCDebug(RuntimeSchedulerLog) << this;
18}
19
21{
22 qCDebug(RuntimeSchedulerLog) << this;
23}
24
26{
27 return QThread::currentThread() == thread();
28}
29
30bool RuntimeScheduler::_canSchedule(QObject* context, std::chrono::microseconds delay, const Callback& callback) const
31{
32 return _isCurrentThread() && context && callback && context->thread() == thread() && delay <= MAX_DELAY;
33}
#define QGC_LOGGING_CATEGORY(name, categoryStr)
Qt event-loop implementation; no callback runs inside schedule().
~RuntimeScheduler() override
bool _canSchedule(QObject *context, std::chrono::microseconds delay, const Callback &callback) const
static constexpr auto MAX_DELAY
RuntimeScheduler(QObject *parent=nullptr)
bool _isCurrentThread() const
std::function< void()> Callback