1#ifndef ATTACHMENT_QUEUE_MANAGER_H
2#define ATTACHMENT_QUEUE_MANAGER_H
24 explicit AttachmentTask(
const std::function<
void()> &taskFunc, QObject *parent =
nullptr);
69 void AddTask(
const std::function<
void()> &TaskFunc);
QList< AttachmentTask * > active_tasks_
List storing tasks currently being executed by the thread pool. Access protected by mutex_.
Definition attachment_queue_manager.h:90
QMutex mutex_
Mutex ensuring thread-safe access to task_queue_ and active_tasks_.
Definition attachment_queue_manager.h:92
int max_active_tasks_
Maximum number of tasks allowed to run concurrently.
Definition attachment_queue_manager.h:94
AttachmentQueueManager(QObject *parent=nullptr)
Private constructor to enforce the singleton pattern. Determines the maximum number of concurrent tas...
Definition attachment_queue_manager.cpp:30
void AddTask(const std::function< void()> &TaskFunc)
Adds a new task (represented by a std::function) to the execution queue. Creates an AttachmentTask wr...
Definition attachment_queue_manager.cpp:15
void ProcessQueue()
Processes the task queue, starting new tasks if slots are available. Checks if the number of active t...
Definition attachment_queue_manager.cpp:34
static AttachmentQueueManager * GetInstance()
Gets the singleton instance of the AttachmentQueueManager.
Definition attachment_queue_manager.h:58
QQueue< AttachmentTask * > task_queue_
Queue storing tasks waiting to be executed. Access protected by mutex_.
Definition attachment_queue_manager.h:88
void finished()
Emitted after the task function (TaskFunc_) has finished executing.
std::function< void()> TaskFunc_
The function object that represents the task to be executed.
Definition attachment_queue_manager.h:40
AttachmentTask(const std::function< void()> &taskFunc, QObject *parent=nullptr)
Constructs an AttachmentTask.
Definition attachment_queue_manager.cpp:5
void run() override
Executes the stored task function (TaskFunc_). Called by the QThreadPool when the task is started....
Definition attachment_queue_manager.cpp:10