Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
taskscheduler.h
Go to the documentation of this file.
1//#
2//# Copyright (C) 2021-2024 QuasarApp.
3//# Distributed under the lgplv3 software license, see the accompanying
4//# Everyone is permitted to copy and distribute verbatim copies
5//# of this license document, but changing it is not allowed.
6//#
7
8#ifndef TASKSCHEDULER_H
9#define TASKSCHEDULER_H
10
11#include "abstracttask.h"
12
13#include <QHash>
14#include <QMap>
15#include <QSharedPointer>
16#include <QTimer>
17
18namespace QH {
19
24class TaskScheduler: public QObject
25{
26 Q_OBJECT
27public:
30
36 bool shedule(const QSharedPointer<AbstractTask>& task);
37
43 bool remove(const QSharedPointer<AbstractTask>& task);
44
50 bool remove(int task);
51
56 int taskCount() const;
57
58signals:
63 void sigPushWork(QSharedPointer<QH::AbstractTask> work);
64
65private slots:
66 void handleTimeOut();
67
68private:
69 int getTimeout(qint64 timeout);
70
71
72 QMultiMap<quint64, int> _taskQueue;
73 QHash<int, QSharedPointer<AbstractTask>> _taskPool;
74 QTimer *_timer = nullptr;
75};
76}
77#endif // TASKSCHEDULER_H
The TaskScheduler class This class contains queue of all shedule tasks.
void sigPushWork(QSharedPointer< QH::AbstractTask > work)
sigPushWork This signal emited when the task work neet to execute.
bool shedule(const QSharedPointer< AbstractTask > &task)
shedule This method shedule new task in this node.
int taskCount() const
taskCount This method return tasks count.
bool remove(const QSharedPointer< AbstractTask > &task)
remove This method remove the task from a tasks queue.
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13