mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-22 04:46:11 +00:00
37 lines
506 B
C
37 lines
506 B
C
|
|
||
|
#ifndef ASYNCTASK_H
|
||
|
#define ASYNCTASK_H
|
||
|
|
||
|
#include <QRunnable>
|
||
|
#include <QThreadPool>
|
||
|
|
||
|
class AsyncTask : public QObject, public QRunnable
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
void run() override final;
|
||
|
|
||
|
virtual void runTask() =0;
|
||
|
|
||
|
signals:
|
||
|
void finished();
|
||
|
};
|
||
|
|
||
|
|
||
|
class AsyncTaskManager : public QObject
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
private:
|
||
|
QThreadPool *threadPool;
|
||
|
|
||
|
public:
|
||
|
explicit AsyncTaskManager(QObject *parent = nullptr);
|
||
|
~AsyncTaskManager();
|
||
|
|
||
|
void start(AsyncTask *task);
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif //ASYNCTASK_H
|