summaryrefslogtreecommitdiffstats
path: root/common/clientapi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/clientapi.cpp')
-rw-r--r--common/clientapi.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp
index a98340c..8bb244c 100644
--- a/common/clientapi.cpp
+++ b/common/clientapi.cpp
@@ -5,26 +5,24 @@
5#include "resourcefacade.h" 5#include "resourcefacade.h"
6#include "log.h" 6#include "log.h"
7#include <QtConcurrent/QtConcurrentRun> 7#include <QtConcurrent/QtConcurrentRun>
8#define ASYNCINTHREAD
9#ifndef ASYNCINTHREAD
10#include <QTimer> 8#include <QTimer>
11#endif 9
10#define ASYNCINTHREAD
12 11
13namespace async 12namespace async
14{ 13{
15 void run(const std::function<void()> &runner) { 14 void run(const std::function<void()> &runner) {
16#ifndef ASYNCINTHREAD
17 auto timer = new QTimer(); 15 auto timer = new QTimer();
18 timer->setSingleShot(true); 16 timer->setSingleShot(true);
19 QObject::connect(timer, &QTimer::timeout, [runner, timer]() { 17 QObject::connect(timer, &QTimer::timeout, [runner, timer]() {
20 delete timer; 18 delete timer;
19#ifndef ASYNCINTHREAD
21 runner(); 20 runner();
22 });
23 timer->start(0);
24#else 21#else
25 //TODO use a job that runs in a thread? 22 QtConcurrent::run(runner);
26 QtConcurrent::run(runner);
27#endif 23#endif
24 });
25 timer->start(0);
28 }; 26 };
29} // namespace async 27} // namespace async
30 28