40 , ReqTimer_ (new QTimer (this))
43 ReqTimer_->setSingleShot (
true);
52 const auto& now = QDateTime::currentDateTime ();
55 Queue_.prepend ({ f, dep ? OptionalTracker_t { dep } : OptionalTracker_t () });
57 Queue_.append ({ f, dep ? OptionalTracker_t { dep } : OptionalTracker_t () });
59 const auto diff = LastRequest_.msecsTo (now);
62 else if (Queue_.size () == 1)
63 ReqTimer_->start (Timeout_ - diff);
85 ReqTimer_->start (Timeout_);
88 void QueueManager::exec ()
90 if (Queue_.isEmpty ())
96 const auto& pair = Queue_.takeFirst ();
97 if (pair.second && !*pair.second)
104 LastRequest_ = QDateTime::currentDateTime ();
106 if (!Queue_.isEmpty ())
107 ReqTimer_->start (Timeout_);
void Schedule(std::function< void()> functor, QObject *dependent=0, QueuePriority prio=QueuePriority::Normal)
Adds the given functor.
bool IsPaused() const
Checks if the queue is paused.
void Pause()
Pauses the queue rotation.
void Clear()
Clears the queue.
QueuePriority
The priority of the action in the queue.
QueueManager(int timeout, QObject *parent=nullptr)
Creates a queue manager with the given timeout.
void Resume()
Continues the queue rotation.