22 ReqTimer_->setSingleShot (
true);
31 const auto&
now = QDateTime::currentDateTime ();
34 Queue_.prepend ({ f,
dep ? OptionalTracker_t {
dep } : OptionalTracker_t () });
36 Queue_.append ({ f,
dep ? OptionalTracker_t {
dep } : OptionalTracker_t () });
38 const auto diff = LastRequest_.msecsTo (
now);
41 else if (Queue_.size () == 1)
42 ReqTimer_->start (Timeout_ -
diff);
64 ReqTimer_->start (Timeout_);
67 void QueueManager::exec ()
69 if (Queue_.isEmpty ())
75 const auto& pair = Queue_.takeFirst ();
76 if (pair.second && !*pair.second)
83 LastRequest_ = QDateTime::currentDateTime ();
85 if (!Queue_.isEmpty ())
86 ReqTimer_->start (Timeout_);
void Resume()
Continues the queue rotation.
bool IsPaused() const
Checks if the queue is paused.
void Clear()
Clears the queue.
void Pause()
Pauses the queue rotation.
void Schedule(std::function< void()> functor, QObject *dependent=nullptr, QueuePriority prio=QueuePriority::Normal)
Adds the given functor.
QueueManager(int timeout, QObject *parent=nullptr)
Creates a queue manager with the given timeout.
Container< T > Filter(const Container< T > &c, F f)
QueuePriority
The priority of the action in the queue.