diff options
Diffstat (limited to 'async/src/async.cpp')
-rw-r--r-- | async/src/async.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/async/src/async.cpp b/async/src/async.cpp index 0e86a84..c57c9ad 100644 --- a/async/src/async.cpp +++ b/async/src/async.cpp | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <QEventLoop> | 22 | #include <QEventLoop> |
23 | #include <QTimer> | 23 | #include <QTimer> |
24 | 24 | ||
25 | using namespace Async; | 25 | using namespace KAsync; |
26 | 26 | ||
27 | Private::Execution::Execution(const Private::ExecutorBasePtr &executor) | 27 | Private::Execution::Execution(const Private::ExecutorBasePtr &executor) |
28 | : executor(executor) | 28 | : executor(executor) |
@@ -104,11 +104,11 @@ static void asyncWhile(const std::function<void(std::function<void(bool)>)> &bod | |||
104 | }); | 104 | }); |
105 | } | 105 | } |
106 | 106 | ||
107 | Job<void> Async::dowhile(Condition condition, ThenTask<void> body) | 107 | Job<void> KAsync::dowhile(Condition condition, ThenTask<void> body) |
108 | { | 108 | { |
109 | return Async::start<void>([body, condition](Async::Future<void> &future) { | 109 | return KAsync::start<void>([body, condition](KAsync::Future<void> &future) { |
110 | asyncWhile([condition, body](std::function<void(bool)> whileCallback) { | 110 | asyncWhile([condition, body](std::function<void(bool)> whileCallback) { |
111 | Async::start<void>(body).then<void>([whileCallback, condition]() { | 111 | KAsync::start<void>(body).then<void>([whileCallback, condition]() { |
112 | whileCallback(!condition()); | 112 | whileCallback(!condition()); |
113 | }).exec(); | 113 | }).exec(); |
114 | }, | 114 | }, |
@@ -118,11 +118,11 @@ Job<void> Async::dowhile(Condition condition, ThenTask<void> body) | |||
118 | }); | 118 | }); |
119 | } | 119 | } |
120 | 120 | ||
121 | Job<void> Async::dowhile(ThenTask<bool> body) | 121 | Job<void> KAsync::dowhile(ThenTask<bool> body) |
122 | { | 122 | { |
123 | return Async::start<void>([body](Async::Future<void> &future) { | 123 | return KAsync::start<void>([body](KAsync::Future<void> &future) { |
124 | asyncWhile([body](std::function<void(bool)> whileCallback) { | 124 | asyncWhile([body](std::function<void(bool)> whileCallback) { |
125 | Async::start<bool>(body).then<bool, bool>([whileCallback](bool result) { | 125 | KAsync::start<bool>(body).then<bool, bool>([whileCallback](bool result) { |
126 | whileCallback(!result); | 126 | whileCallback(!result); |
127 | //FIXME this return value is only required because .then<bool, void> doesn't work | 127 | //FIXME this return value is only required because .then<bool, void> doesn't work |
128 | return true; | 128 | return true; |
@@ -134,10 +134,10 @@ Job<void> Async::dowhile(ThenTask<bool> body) | |||
134 | }); | 134 | }); |
135 | } | 135 | } |
136 | 136 | ||
137 | Job<void> Async::wait(int delay) | 137 | Job<void> KAsync::wait(int delay) |
138 | { | 138 | { |
139 | auto timer = QSharedPointer<QTimer>::create(); | 139 | auto timer = QSharedPointer<QTimer>::create(); |
140 | return Async::start<void>([timer, delay](Async::Future<void> &future) { | 140 | return KAsync::start<void>([timer, delay](KAsync::Future<void> &future) { |
141 | timer->setSingleShot(true); | 141 | timer->setSingleShot(true); |
142 | QObject::connect(timer.data(), &QTimer::timeout, [&future]() { | 142 | QObject::connect(timer.data(), &QTimer::timeout, [&future]() { |
143 | future.setFinished(); | 143 | future.setFinished(); |