6#include <QtCore/QTimerEvent>
15 qCDebug(QtRuntimeSchedulerLog) <<
this;
20 qCDebug(QtRuntimeSchedulerLog) <<
this;
34 const int timer = startTimer((std::max) (delay, std::chrono::microseconds::zero()), Qt::PreciseTimer);
38 const auto id = ++_nextTask;
39 const auto contextDestroyed = connect(context, &QObject::destroyed,
this, [
this,
id]() {
cancel(
id); });
40 _tasks.insert(timer, {id, context, std::move(callback), contextDestroyed});
41 _timers.insert(
id, timer);
50 const auto timer = _timers.find(task);
51 if (timer == _timers.end()) {
55 disconnect(_tasks.take(*timer).contextDestroyed);
61 const auto found = _tasks.find(event->timerId());
62 if (found == _tasks.end()) {
63 RuntimeScheduler::timerEvent(event);
66 killTimer(found.key());
67 Task task = std::move(*found);
69 _timers.remove(task.id);
70 disconnect(task.contextDestroyed);
std::function< void()> Task
#define QGC_LOGGING_CATEGORY(name, categoryStr)
Qt event-loop implementation; no callback runs inside schedule().
void cancel(TaskId task) override
Cancellation from another thread is ignored. All other access and destruction must occur on the owner...
~QtRuntimeScheduler() override
void timerEvent(QTimerEvent *event) override
TaskId schedule(QObject *context, std::chrono::microseconds delay, Callback callback) override
quint64 nowUs() const override
bool _canSchedule(QObject *context, std::chrono::microseconds delay, const Callback &callback) const
bool _isCurrentThread() const
std::function< void()> Callback