added namespaces
This commit is contained in:
+20
-2
@@ -1,13 +1,31 @@
|
||||
#ifndef ASYNCEXEC_H
|
||||
#define ASYNCEXEC_H
|
||||
|
||||
#include "lambdaqrunnable.h"
|
||||
#include "qcoreapplication.h"
|
||||
|
||||
#include <QRunnable>
|
||||
#include <QThreadPool>
|
||||
#include <functional>
|
||||
|
||||
#define async_exec(a) \
|
||||
QThreadPool::globalInstance()->start(new LambdaQRunnable(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
|
||||
|
||||
Reference in New Issue
Block a user