45 const auto& now = QDateTime::currentDateTime ();
46 Queue_.push_back ({ f, dep ? OptionalTracker_t { dep } : OptionalTracker_t () });
48 const auto diff = LastRequest_.msecsTo (now);
51 else if (Queue_.size () == 1)
52 QTimer::singleShot (Timeout_ - diff,
57 void QueueManager::exec ()
59 if (Queue_.isEmpty ())
62 const auto& pair = Queue_.takeFirst ();
63 if (pair.second && !*pair.second)
70 LastRequest_ = QDateTime::currentDateTime ();
72 if (!Queue_.isEmpty ())
73 QTimer::singleShot (Timeout_,
UTIL_API void Schedule(std::function< void()> functor, QObject *dependent=0)
Adds the given functor.
UTIL_API QueueManager(int timeout, QObject *parent=0)
Creates a queue manager with the given timeout.