mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
29 lines
488 B
C++
29 lines
488 B
C++
#ifndef ASYNCEXEC_H
|
|
#define ASYNCEXEC_H
|
|
|
|
#include "qcoreapplication.h"
|
|
|
|
#include <QRunnable>
|
|
#include <QThreadPool>
|
|
#include <functional>
|
|
|
|
#define async_exec(a) QThreadPool::globalInstance()->start(new LambdaRunnable(a));
|
|
|
|
class LambdaRunnable : public QRunnable {
|
|
public:
|
|
LambdaRunnable(std::function<void()> action)
|
|
{
|
|
this->action = action;
|
|
}
|
|
|
|
void run()
|
|
{
|
|
this->action();
|
|
}
|
|
|
|
private:
|
|
std::function<void()> action;
|
|
};
|
|
|
|
#endif // ASYNCEXEC_H
|