diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-23 19:43:45 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-23 19:47:31 +0200 |
commit | 71aace61b7b1c27ac9296a882b209fe966be5848 (patch) | |
tree | 338725a4cf02dadffd8c6c89b1f7009052c762be /common/clientapi.cpp | |
parent | 3dcf0aa57f9fae49f429c2c860f5b96887e5e04a (diff) | |
download | sink-71aace61b7b1c27ac9296a882b209fe966be5848.tar.gz sink-71aace61b7b1c27ac9296a882b209fe966be5848.zip |
An easy way to switch between threaded and non-threaded query execution
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 | ||