![]() |
LeechCraft
0.6.70-10870-g558588d6ec
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 64 of file queuemanager.h.
LeechCraft::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 37 of file queuemanager.cpp.
void LeechCraft::Util::QueueManager::Clear | ( | ) |
Clears the queue.
Clears the remaining items in the queue, but doesn't abort the current operation.
Definition at line 66 of file queuemanager.cpp.
bool LeechCraft::Util::QueueManager::IsPaused | ( | ) | const |
Checks if the queue is paused.
Definition at line 77 of file queuemanager.cpp.
void LeechCraft::Util::QueueManager::Pause | ( | ) |
Pauses the queue rotation.
If the queue is already paused, this function does nothing.
Definition at line 71 of file queuemanager.cpp.
void LeechCraft::Util::QueueManager::Resume | ( | ) |
Continues the queue rotation.
If the queue is already running, this function does nothing.
Definition at line 82 of file queuemanager.cpp.
void LeechCraft::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 50 of file queuemanager.cpp.
References LeechCraft::Util::oral::sph::f, and LeechCraft::Util::High.