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