![]() |
LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
A simple scheduling manager for a queue of functors. More...
#include "queuemanager.h"
Public Member Functions | |
QueueManager (int timeout, QObject *parent=nullptr) | |
Creates a queue manager with the given timeout. More... | |
void | Schedule (std::function< void()> functor, QObject *dependent=nullptr, QueuePriority prio=QueuePriority::Normal) |
Adds the given functor. More... | |
void | Clear () |
Clears the queue. More... | |
void | Pause () |
Pauses the queue rotation. More... | |
bool | IsPaused () const |
Checks if the queue is paused. More... | |
void | Resume () |
Continues the queue rotation. More... | |
A simple scheduling manager for a queue of functors.
This class manages execution of functors that should be called with some minimal timeout between them.
Definition at line 43 of file queuemanager.h.
LC::Util::QueueManager::QueueManager | ( | int | timeout, |
QObject * | parent = nullptr |
||
) |
Creates a queue manager with the given timeout.
[in] | timeout | The timeout between invoking the functions in milliseconds. |
[in] | parent | The parent object of this queue manager. |
Definition at line 28 of file queuemanager.cpp.
References LC::Util::oral::sph::f.
void LC::Util::QueueManager::Clear | ( | ) |
Clears the queue.
Clears the remaining items in the queue, but doesn't abort the current operation.
Definition at line 57 of file queuemanager.cpp.
bool LC::Util::QueueManager::IsPaused | ( | ) | const |
Checks if the queue is paused.
Definition at line 68 of file queuemanager.cpp.
void LC::Util::QueueManager::Pause | ( | ) |
Pauses the queue rotation.
If the queue is already paused, this function does nothing.
Definition at line 62 of file queuemanager.cpp.
void LC::Util::QueueManager::Resume | ( | ) |
Continues the queue rotation.
If the queue is already running, this function does nothing.
Definition at line 73 of file queuemanager.cpp.
void LC::Util::QueueManager::Schedule | ( | std::function< void()> | functor, |
QObject * | dependent = nullptr , |
||
QueuePriority | prio = QueuePriority::Normal |
||
) |
Adds the given functor.
This function adds the given functor to the execution queue, or executes it right at the point of adding if more than timeout has passed since executing the last functor.
dependent is an object this functor depends upon. If dependent object is destructed by the time queue reaches the passed functor, the functor will be skipped and next scheduled functor will be executed (if any).
[in] | functor | The functor to add to the queue. |
[in] | dependent | The dependent object, or nullptr if this functor doesn't depend on anything. |
[in] | prio | The priority of the functor. Functors with high priority are added to the beginning of the queue. |
Definition at line 41 of file queuemanager.cpp.
Referenced by LC::Util::SvcAuth::VkAuthManager::SetSilentMode().