diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
commit | 4d9746c828558c9f872e0aed52442863affb25d5 (patch) | |
tree | 507d7c2ba67f47d3cbbcf01a722236ff1b48426b /common/asyncutils.h | |
parent | 9cea920b7dd51867a0be0fed2f461b6be73c103e (diff) | |
download | sink-4d9746c828558c9f872e0aed52442863affb25d5.tar.gz sink-4d9746c828558c9f872e0aed52442863affb25d5.zip |
Fromatted the whole codebase with clang-format.
clang-format -i */**{.cpp,.h}
Diffstat (limited to 'common/asyncutils.h')
-rw-r--r-- | common/asyncutils.h | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/common/asyncutils.h b/common/asyncutils.h index ddcc37c..2cf010e 100644 --- a/common/asyncutils.h +++ b/common/asyncutils.h | |||
@@ -24,19 +24,18 @@ | |||
24 | #include <QFutureWatcher> | 24 | #include <QFutureWatcher> |
25 | 25 | ||
26 | namespace async { | 26 | namespace async { |
27 | template<typename T> | 27 | template <typename T> |
28 | KAsync::Job<T> run(const std::function<T()> &f) | 28 | KAsync::Job<T> run(const std::function<T()> &f) |
29 | { | 29 | { |
30 | return KAsync::start<T>([f](KAsync::Future<T> &future) { | 30 | return KAsync::start<T>([f](KAsync::Future<T> &future) { |
31 | auto result = QtConcurrent::run(f); | 31 | auto result = QtConcurrent::run(f); |
32 | auto watcher = new QFutureWatcher<T>; | 32 | auto watcher = new QFutureWatcher<T>; |
33 | watcher->setFuture(result); | 33 | watcher->setFuture(result); |
34 | QObject::connect(watcher, &QFutureWatcher<T>::finished, watcher, [&future, watcher]() { | 34 | QObject::connect(watcher, &QFutureWatcher<T>::finished, watcher, [&future, watcher]() { |
35 | future.setValue(watcher->future().result()); | 35 | future.setValue(watcher->future().result()); |
36 | delete watcher; | 36 | delete watcher; |
37 | future.setFinished(); | 37 | future.setFinished(); |
38 | }); | ||
39 | }); | 38 | }); |
40 | } | 39 | }); |
41 | 40 | } | |
42 | } | 41 | } |