summaryrefslogtreecommitdiffstats
path: root/async/src
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2015-05-15 16:00:32 +0200
committerDan Vrátil <dvratil@redhat.com>2015-05-15 16:22:28 +0200
commit5b78e0da1d64b6096829f54b29f14ec5643b5ece (patch)
tree2091795596f9721bc1d9d8cb9965103d5a32df7a /async/src
parent3bbee6c42683db5f85b01e4eb6dab8135e199f6c (diff)
downloadsink-5b78e0da1d64b6096829f54b29f14ec5643b5ece.tar.gz
sink-5b78e0da1d64b6096829f54b29f14ec5643b5ece.zip
Async: rename Async namespace to KAsync
Diffstat (limited to 'async/src')
-rw-r--r--async/src/async.cpp18
-rw-r--r--async/src/async.h134
-rw-r--r--async/src/async_impl.h20
-rw-r--r--async/src/debug.cpp16
-rw-r--r--async/src/debug.h16
-rw-r--r--async/src/future.cpp4
-rw-r--r--async/src/future.h52
7 files changed, 133 insertions, 127 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
25using namespace Async; 25using namespace KAsync;
26 26
27Private::Execution::Execution(const Private::ExecutorBasePtr &executor) 27Private::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
107Job<void> Async::dowhile(Condition condition, ThenTask<void> body) 107Job<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
121Job<void> Async::dowhile(ThenTask<bool> body) 121Job<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
137Job<void> Async::wait(int delay) 137Job<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();
diff --git a/async/src/async.h b/async/src/async.h
index b1f1121..152f98e 100644
--- a/async/src/async.h
+++ b/async/src/async.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2014 Daniel Vrátil <dvratil@redhat.com> 2 * Copyright 2014 - 2015 Daniel Vrátil <dvratil@redhat.com>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public License as 5 * modify it under the terms of the GNU Library General Public License as
@@ -15,8 +15,10 @@
15 * along with this library. If not, see <http://www.gnu.org/licenses/>. 15 * along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18#ifndef ASYNC_H 18#ifndef KASYNC_H
19#define ASYNC_H 19#define KASYNC_H
20
21#include "kasync_export.h"
20 22
21#include <functional> 23#include <functional>
22#include <list> 24#include <list>
@@ -64,7 +66,7 @@
64 * TODO: Possibility to abort a job through future (perhaps optional?) 66 * TODO: Possibility to abort a job through future (perhaps optional?)
65 * TODO: Support for timeout, specified during exec call, after which the error handler gets called with a defined errorCode. 67 * TODO: Support for timeout, specified during exec call, after which the error handler gets called with a defined errorCode.
66 */ 68 */
67namespace Async { 69namespace KAsync {
68 70
69template<typename PrevOut, typename Out, typename ... In> 71template<typename PrevOut, typename Out, typename ... In>
70class Executor; 72class Executor;
@@ -75,15 +77,15 @@ template<typename Out, typename ... In>
75class Job; 77class Job;
76 78
77template<typename Out, typename ... In> 79template<typename Out, typename ... In>
78using ThenTask = typename detail::identity<std::function<void(In ..., Async::Future<Out>&)>>::type; 80using ThenTask = typename detail::identity<std::function<void(In ..., KAsync::Future<Out>&)>>::type;
79template<typename Out, typename ... In> 81template<typename Out, typename ... In>
80using SyncThenTask = typename detail::identity<std::function<Out(In ...)>>::type; 82using SyncThenTask = typename detail::identity<std::function<Out(In ...)>>::type;
81template<typename Out, typename In> 83template<typename Out, typename In>
82using EachTask = typename detail::identity<std::function<void(In, Async::Future<Out>&)>>::type; 84using EachTask = typename detail::identity<std::function<void(In, KAsync::Future<Out>&)>>::type;
83template<typename Out, typename In> 85template<typename Out, typename In>
84using SyncEachTask = typename detail::identity<std::function<Out(In)>>::type; 86using SyncEachTask = typename detail::identity<std::function<Out(In)>>::type;
85template<typename Out, typename In> 87template<typename Out, typename In>
86using ReduceTask = typename detail::identity<std::function<void(In, Async::Future<Out>&)>>::type; 88using ReduceTask = typename detail::identity<std::function<void(In, KAsync::Future<Out>&)>>::type;
87template<typename Out, typename In> 89template<typename Out, typename In>
88using SyncReduceTask = typename detail::identity<std::function<Out(In)>>::type; 90using SyncReduceTask = typename detail::identity<std::function<Out(In)>>::type;
89 91
@@ -96,15 +98,15 @@ namespace Private
96class ExecutorBase; 98class ExecutorBase;
97typedef QSharedPointer<ExecutorBase> ExecutorBasePtr; 99typedef QSharedPointer<ExecutorBase> ExecutorBasePtr;
98 100
99struct Execution { 101struct KASYNC_EXPORT Execution {
100 Execution(const ExecutorBasePtr &executor); 102 Execution(const ExecutorBasePtr &executor);
101 ~Execution(); 103 ~Execution();
102 void setFinished(); 104 void setFinished();
103 105
104 template<typename T> 106 template<typename T>
105 Async::Future<T>* result() const 107 KAsync::Future<T>* result() const
106 { 108 {
107 return static_cast<Async::Future<T>*>(resultBase); 109 return static_cast<KAsync::Future<T>*>(resultBase);
108 } 110 }
109 111
110 void releaseFuture(); 112 void releaseFuture();
@@ -125,16 +127,16 @@ struct Execution {
125 127
126typedef QSharedPointer<Execution> ExecutionPtr; 128typedef QSharedPointer<Execution> ExecutionPtr;
127 129
128class ExecutorBase 130class KASYNC_EXPORT ExecutorBase
129{ 131{
130 template<typename PrevOut, typename Out, typename ... In> 132 template<typename PrevOut, typename Out, typename ... In>
131 friend class Executor; 133 friend class Executor;
132 134
133 template<typename Out, typename ... In> 135 template<typename Out, typename ... In>
134 friend class Async::Job; 136 friend class KAsync::Job;
135 137
136 friend class Execution; 138 friend class Execution;
137 friend class Async::Tracer; 139 friend class KAsync::Tracer;
138 140
139public: 141public:
140 virtual ~ExecutorBase(); 142 virtual ~ExecutorBase();
@@ -144,7 +146,7 @@ protected:
144 ExecutorBase(const ExecutorBasePtr &parent); 146 ExecutorBase(const ExecutorBasePtr &parent);
145 147
146 template<typename T> 148 template<typename T>
147 Async::Future<T>* createFuture(const ExecutionPtr &execution) const; 149 KAsync::Future<T>* createFuture(const ExecutionPtr &execution) const;
148 150
149 virtual bool hasErrorFunc() const = 0; 151 virtual bool hasErrorFunc() const = 0;
150 virtual bool handleError(const ExecutionPtr &execution) = 0; 152 virtual bool handleError(const ExecutionPtr &execution) = 0;
@@ -193,7 +195,7 @@ public:
193 void run(const ExecutionPtr &execution); 195 void run(const ExecutionPtr &execution);
194private: 196private:
195 EachTask<Out, In> mFunc; 197 EachTask<Out, In> mFunc;
196 QVector<Async::FutureWatcher<Out>*> mFutureWatchers; 198 QVector<KAsync::FutureWatcher<Out>*> mFutureWatchers;
197}; 199};
198 200
199template<typename Out, typename In> 201template<typename Out, typename In>
@@ -234,8 +236,8 @@ public:
234 SyncEachExecutor(SyncEachTask<Out, In> each, ErrorHandler errorFunc, const ExecutorBasePtr &parent); 236 SyncEachExecutor(SyncEachTask<Out, In> each, ErrorHandler errorFunc, const ExecutorBasePtr &parent);
235 void run(const ExecutionPtr &execution); 237 void run(const ExecutionPtr &execution);
236private: 238private:
237 void run(Async::Future<Out> *future, const typename PrevOut::value_type &arg, std::false_type); // !std::is_void<Out> 239 void run(KAsync::Future<Out> *future, const typename PrevOut::value_type &arg, std::false_type); // !std::is_void<Out>
238 void run(Async::Future<Out> *future, const typename PrevOut::value_type &arg, std::true_type); // std::is_void<Out> 240 void run(KAsync::Future<Out> *future, const typename PrevOut::value_type &arg, std::true_type); // std::is_void<Out>
239 SyncEachTask<Out, In> mFunc; 241 SyncEachTask<Out, In> mFunc;
240}; 242};
241 243
@@ -244,11 +246,11 @@ private:
244/** 246/**
245 * Start an asynchronous job sequence. 247 * Start an asynchronous job sequence.
246 * 248 *
247 * Async::start() is your starting point to build a chain of jobs to be executed 249 * KAsync::start() is your starting point to build a chain of jobs to be executed
248 * asynchronously. 250 * asynchronously.
249 * 251 *
250 * @param func An asynchronous function to be executed. The function must have 252 * @param func An asynchronous function to be executed. The function must have
251 * void return type, and accept exactly one argument of type @p Async::Future<In>, 253 * void return type, and accept exactly one argument of type @p KAsync::Future<In>,
252 * where @p In is type of the result. 254 * where @p In is type of the result.
253 */ 255 */
254template<typename Out, typename ... In> 256template<typename Out, typename ... In>
@@ -267,14 +269,14 @@ Job<ReturnType, Args ...> start();
267 * 269 *
268 * The loop continues while @param condition returns true. 270 * The loop continues while @param condition returns true.
269 */ 271 */
270Job<void> dowhile(Condition condition, ThenTask<void> func); 272KASYNC_EXPORT Job<void> dowhile(Condition condition, ThenTask<void> func);
271 273
272/** 274/**
273 * Async while loop. 275 * Async while loop.
274 * 276 *
275 * Loop continues while body returns true. 277 * Loop continues while body returns true.
276 */ 278 */
277Job<void> dowhile(ThenTask<bool> body); 279KASYNC_EXPORT Job<void> dowhile(ThenTask<bool> body);
278 280
279/** 281/**
280 * Iterate over a container. 282 * Iterate over a container.
@@ -287,7 +289,7 @@ Job<Out> iterate(const Out &container);
287/** 289/**
288 * Async delay. 290 * Async delay.
289 */ 291 */
290Job<void> wait(int delay); 292KASYNC_EXPORT Job<void> wait(int delay);
291 293
292/** 294/**
293 * A null job. 295 * A null job.
@@ -307,7 +309,7 @@ Job<Out> null();
307template<typename Out> 309template<typename Out>
308Job<Out> error(int errorCode = 1, const QString &errorMessage = QString()); 310Job<Out> error(int errorCode = 1, const QString &errorMessage = QString());
309 311
310class JobBase 312class KASYNC_EXPORT JobBase
311{ 313{
312 template<typename Out, typename ... In> 314 template<typename Out, typename ... In>
313 friend class Job; 315 friend class Job;
@@ -324,18 +326,18 @@ protected:
324 * An Asynchronous job 326 * An Asynchronous job
325 * 327 *
326 * A single instance of Job represents a single method that will be executed 328 * A single instance of Job represents a single method that will be executed
327 * asynchrously. The Job is started by @p Job::exec(), which returns @p Async::Future 329 * asynchrously. The Job is started by @p Job::exec(), which returns @p KAsync::Future
328 * immediatelly. The Future will be set to finished state once the asynchronous 330 * immediatelly. The Future will be set to finished state once the asynchronous
329 * task has finished. You can use @p Async::Future::waitForFinished() to wait for 331 * task has finished. You can use @p KAsync::Future::waitForFinished() to wait for
330 * for the Future in blocking manner. 332 * for the Future in blocking manner.
331 * 333 *
332 * It is possible to chain multiple Jobs one after another in different fashion 334 * It is possible to chain multiple Jobs one after another in different fashion
333 * (sequential, parallel, etc.). Calling Job::exec() will then return a pending 335 * (sequential, parallel, etc.). Calling Job::exec() will then return a pending
334 * @p Async::Future, and will execute the entire chain of jobs. 336 * @p KAsync::Future, and will execute the entire chain of jobs.
335 * 337 *
336 * @code 338 * @code
337 * auto job = Job::start<QList<int>>( 339 * auto job = Job::start<QList<int>>(
338 * [](Async::Future<QList<int>> &future) { 340 * [](KAsync::Future<QList<int>> &future) {
339 * MyREST::PendingUsers *pu = MyREST::requestListOfUsers(); 341 * MyREST::PendingUsers *pu = MyREST::requestListOfUsers();
340 * QObject::connect(pu, &PendingOperation::finished, 342 * QObject::connect(pu, &PendingOperation::finished,
341 * [&](PendingOperation *pu) { 343 * [&](PendingOperation *pu) {
@@ -344,7 +346,7 @@ protected:
344 * }); 346 * });
345 * }) 347 * })
346 * .each<QList<MyREST::User>, int>( 348 * .each<QList<MyREST::User>, int>(
347 * [](const int &userId, Async::Future<QList<MyREST::User>> &future) { 349 * [](const int &userId, KAsync::Future<QList<MyREST::User>> &future) {
348 * MyREST::PendingUser *pu = MyREST::requestUserDetails(userId); 350 * MyREST::PendingUser *pu = MyREST::requestUserDetails(userId);
349 * QObject::connect(pu, &PendingOperation::finished, 351 * QObject::connect(pu, &PendingOperation::finished,
350 * [&](PendingOperation *pu) { 352 * [&](PendingOperation *pu) {
@@ -353,7 +355,7 @@ protected:
353 * }); 355 * });
354 * }); 356 * });
355 * 357 *
356 * Async::Future<QList<MyREST::User>> usersFuture = job.exec(); 358 * KAsync::Future<QList<MyREST::User>> usersFuture = job.exec();
357 * usersFuture.waitForFinished(); 359 * usersFuture.waitForFinished();
358 * QList<MyRest::User> users = usersFuture.value(); 360 * QList<MyRest::User> users = usersFuture.value();
359 * @endcode 361 * @endcode
@@ -369,10 +371,10 @@ class Job : public JobBase
369 friend class Job; 371 friend class Job;
370 372
371 template<typename OutOther, typename ... InOther> 373 template<typename OutOther, typename ... InOther>
372 friend Job<OutOther, InOther ...> start(Async::ThenTask<OutOther, InOther ...> func, ErrorHandler errorFunc); 374 friend Job<OutOther, InOther ...> start(KAsync::ThenTask<OutOther, InOther ...> func, ErrorHandler errorFunc);
373 375
374 template<typename OutOther, typename ... InOther> 376 template<typename OutOther, typename ... InOther>
375 friend Job<OutOther, InOther ...> start(Async::SyncThenTask<OutOther, InOther ...> func, ErrorHandler errorFunc); 377 friend Job<OutOther, InOther ...> start(KAsync::SyncThenTask<OutOther, InOther ...> func, ErrorHandler errorFunc);
376 378
377#ifdef WITH_KJOB 379#ifdef WITH_KJOB
378 template<typename ReturnType, typename KJobType, ReturnType (KJobType::*KJobResultMethod)(), typename ... Args> 380 template<typename ReturnType, typename KJobType, ReturnType (KJobType::*KJobResultMethod)(), typename ... Args>
@@ -454,7 +456,7 @@ public:
454 } 456 }
455 457
456 template<typename FirstIn> 458 template<typename FirstIn>
457 Async::Future<Out> exec(FirstIn in) 459 KAsync::Future<Out> exec(FirstIn in)
458 { 460 {
459 // Inject a fake sync executor that will return the initial value 461 // Inject a fake sync executor that will return the initial value
460 Private::ExecutorBasePtr first = mExecutor; 462 Private::ExecutorBasePtr first = mExecutor;
@@ -474,10 +476,10 @@ public:
474 return result; 476 return result;
475 } 477 }
476 478
477 Async::Future<Out> exec() 479 KAsync::Future<Out> exec()
478 { 480 {
479 Private::ExecutionPtr execution = mExecutor->exec(mExecutor); 481 Private::ExecutionPtr execution = mExecutor->exec(mExecutor);
480 Async::Future<Out> result = *execution->result<Out>(); 482 KAsync::Future<Out> result = *execution->result<Out>();
481 483
482 return result; 484 return result;
483 } 485 }
@@ -499,15 +501,15 @@ private:
499 template<typename InOther> 501 template<typename InOther>
500 void reduceInvariants() 502 void reduceInvariants()
501 { 503 {
502 static_assert(Async::detail::isIterable<Out>::value, 504 static_assert(KAsync::detail::isIterable<Out>::value,
503 "The 'Result' task can only be connected to a job that returns a list or an array"); 505 "The 'Result' task can only be connected to a job that returns a list or an array");
504 static_assert(std::is_same<typename Out::value_type, typename InOther::value_type>::value, 506 static_assert(std::is_same<typename Out::value_type, typename InOther::value_type>::value,
505 "The return type of previous task must be compatible with input type of this task"); 507 "The return type of previous task must be compatible with input type of this task");
506 } 508 }
507 509
508 template<typename OutOther, typename ... InOther> 510 template<typename OutOther, typename ... InOther>
509 inline std::function<void(InOther ..., Async::Future<OutOther>&)> nestedJobWrapper(Job<OutOther, InOther ...> otherJob) { 511 inline std::function<void(InOther ..., KAsync::Future<OutOther>&)> nestedJobWrapper(Job<OutOther, InOther ...> otherJob) {
510 return [otherJob](InOther ... in, Async::Future<OutOther> &future) { 512 return [otherJob](InOther ... in, KAsync::Future<OutOther> &future) {
511 // copy by value is const 513 // copy by value is const
512 auto job = otherJob; 514 auto job = otherJob;
513 FutureWatcher<OutOther> *watcher = new FutureWatcher<OutOther>(); 515 FutureWatcher<OutOther> *watcher = new FutureWatcher<OutOther>();
@@ -518,7 +520,7 @@ private:
518 // in copyFutureValue() 520 // in copyFutureValue()
519 // copy by value is const 521 // copy by value is const
520 auto outFuture = future; 522 auto outFuture = future;
521 Async::detail::copyFutureValue(watcher->future(), outFuture); 523 KAsync::detail::copyFutureValue(watcher->future(), outFuture);
522 if (watcher->future().errorCode()) { 524 if (watcher->future().errorCode()) {
523 outFuture.setError(watcher->future().errorCode(), watcher->future().errorMessage()); 525 outFuture.setError(watcher->future().errorCode(), watcher->future().errorMessage());
524 } else { 526 } else {
@@ -531,12 +533,12 @@ private:
531 } 533 }
532}; 534};
533 535
534} // namespace Async 536} // namespace KAsync
535 537
536 538
537// ********** Out of line definitions **************** 539// ********** Out of line definitions ****************
538 540
539namespace Async { 541namespace KAsync {
540 542
541template<typename Out, typename ... In> 543template<typename Out, typename ... In>
542Job<Out, In ...> start(ThenTask<Out, In ...> func, ErrorHandler error) 544Job<Out, In ...> start(ThenTask<Out, In ...> func, ErrorHandler error)
@@ -557,7 +559,7 @@ template<typename ReturnType, typename KJobType, ReturnType (KJobType::*KJobResu
557Job<ReturnType, Args ...> start() 559Job<ReturnType, Args ...> start()
558{ 560{
559 return Job<ReturnType, Args ...>(Private::ExecutorBasePtr( 561 return Job<ReturnType, Args ...>(Private::ExecutorBasePtr(
560 new Private::ThenExecutor<ReturnType, Args ...>([](const Args & ... args, Async::Future<ReturnType> &future) 562 new Private::ThenExecutor<ReturnType, Args ...>([](const Args & ... args, KAsync::Future<ReturnType> &future)
561 { 563 {
562 KJobType *job = new KJobType(args ...); 564 KJobType *job = new KJobType(args ...);
563 job->connect(job, &KJob::finished, 565 job->connect(job, &KJob::finished,
@@ -578,8 +580,8 @@ Job<ReturnType, Args ...> start()
578template<typename Out> 580template<typename Out>
579Job<Out> null() 581Job<Out> null()
580{ 582{
581 return Async::start<Out>( 583 return KAsync::start<Out>(
582 [](Async::Future<Out> &future) { 584 [](KAsync::Future<Out> &future) {
583 future.setFinished(); 585 future.setFinished();
584 }); 586 });
585} 587}
@@ -587,8 +589,8 @@ Job<Out> null()
587template<typename Out> 589template<typename Out>
588Job<Out> error(int errorCode, const QString &errorMessage) 590Job<Out> error(int errorCode, const QString &errorMessage)
589{ 591{
590 return Async::start<Out>( 592 return KAsync::start<Out>(
591 [errorCode, errorMessage](Async::Future<Out> &future) { 593 [errorCode, errorMessage](KAsync::Future<Out> &future) {
592 future.setError(errorCode, errorMessage); 594 future.setError(errorCode, errorMessage);
593 }); 595 });
594} 596}
@@ -596,7 +598,7 @@ Job<Out> error(int errorCode, const QString &errorMessage)
596template<typename Out> 598template<typename Out>
597Job<Out> iterate(const Out &container) 599Job<Out> iterate(const Out &container)
598{ 600{
599 return Async::start<Out>( 601 return KAsync::start<Out>(
600 [container]() { 602 [container]() {
601 return container; 603 return container;
602 }); 604 });
@@ -606,9 +608,9 @@ Job<Out> iterate(const Out &container)
606namespace Private { 608namespace Private {
607 609
608template<typename T> 610template<typename T>
609Async::Future<T>* ExecutorBase::createFuture(const ExecutionPtr &execution) const 611KAsync::Future<T>* ExecutorBase::createFuture(const ExecutionPtr &execution) const
610{ 612{
611 return new Async::Future<T>(execution); 613 return new KAsync::Future<T>(execution);
612} 614}
613 615
614template<typename PrevOut, typename Out, typename ... In> 616template<typename PrevOut, typename Out, typename ... In>
@@ -625,8 +627,8 @@ ExecutionPtr Executor<PrevOut, Out, In ...>::exec(const ExecutorBasePtr &self)
625 execution->prevExecution = mPrev ? mPrev->exec(mPrev) : ExecutionPtr(); 627 execution->prevExecution = mPrev ? mPrev->exec(mPrev) : ExecutionPtr();
626 628
627 execution->resultBase = ExecutorBase::createFuture<Out>(execution); 629 execution->resultBase = ExecutorBase::createFuture<Out>(execution);
628 auto fw = new Async::FutureWatcher<Out>(); 630 auto fw = new KAsync::FutureWatcher<Out>();
629 QObject::connect(fw, &Async::FutureWatcher<Out>::futureReady, 631 QObject::connect(fw, &KAsync::FutureWatcher<Out>::futureReady,
630 [fw, execution, this]() { 632 [fw, execution, this]() {
631 handleError(execution); 633 handleError(execution);
632 execution->setFinished(); 634 execution->setFinished();
@@ -634,7 +636,7 @@ ExecutionPtr Executor<PrevOut, Out, In ...>::exec(const ExecutorBasePtr &self)
634 }); 636 });
635 fw->setFuture(*execution->result<Out>()); 637 fw->setFuture(*execution->result<Out>());
636 638
637 Async::Future<PrevOut> *prevFuture = execution->prevExecution ? execution->prevExecution->result<PrevOut>() : nullptr; 639 KAsync::Future<PrevOut> *prevFuture = execution->prevExecution ? execution->prevExecution->result<PrevOut>() : nullptr;
638 if (!prevFuture || prevFuture->isFinished()) { 640 if (!prevFuture || prevFuture->isFinished()) {
639 if (prevFuture) { // prevFuture implies execution->prevExecution 641 if (prevFuture) { // prevFuture implies execution->prevExecution
640 if (prevFuture->errorCode()) { 642 if (prevFuture->errorCode()) {
@@ -655,8 +657,8 @@ ExecutionPtr Executor<PrevOut, Out, In ...>::exec(const ExecutorBasePtr &self)
655 execution->isRunning = true; 657 execution->isRunning = true;
656 run(execution); 658 run(execution);
657 } else { 659 } else {
658 auto prevFutureWatcher = new Async::FutureWatcher<PrevOut>(); 660 auto prevFutureWatcher = new KAsync::FutureWatcher<PrevOut>();
659 QObject::connect(prevFutureWatcher, &Async::FutureWatcher<PrevOut>::futureReady, 661 QObject::connect(prevFutureWatcher, &KAsync::FutureWatcher<PrevOut>::futureReady,
660 [prevFutureWatcher, execution, this]() { 662 [prevFutureWatcher, execution, this]() {
661 auto prevFuture = prevFutureWatcher->future(); 663 auto prevFuture = prevFutureWatcher->future();
662 assert(prevFuture.isFinished()); 664 assert(prevFuture.isFinished());
@@ -679,7 +681,7 @@ ExecutionPtr Executor<PrevOut, Out, In ...>::exec(const ExecutorBasePtr &self)
679 run(execution); 681 run(execution);
680 }); 682 });
681 683
682 prevFutureWatcher->setFuture(*static_cast<Async::Future<PrevOut>*>(prevFuture)); 684 prevFutureWatcher->setFuture(*static_cast<KAsync::Future<PrevOut>*>(prevFuture));
683 } 685 }
684 686
685 return execution; 687 return execution;
@@ -712,7 +714,7 @@ ThenExecutor<Out, In ...>::ThenExecutor(ThenTask<Out, In ...> then, ErrorHandler
712template<typename Out, typename ... In> 714template<typename Out, typename ... In>
713void ThenExecutor<Out, In ...>::run(const ExecutionPtr &execution) 715void ThenExecutor<Out, In ...>::run(const ExecutionPtr &execution)
714{ 716{
715 Async::Future<typename detail::prevOut<In ...>::type> *prevFuture = nullptr; 717 KAsync::Future<typename detail::prevOut<In ...>::type> *prevFuture = nullptr;
716 if (execution->prevExecution) { 718 if (execution->prevExecution) {
717 prevFuture = execution->prevExecution->result<typename detail::prevOut<In ...>::type>(); 719 prevFuture = execution->prevExecution->result<typename detail::prevOut<In ...>::type>();
718 assert(prevFuture->isFinished()); 720 assert(prevFuture->isFinished());
@@ -744,17 +746,17 @@ void EachExecutor<PrevOut, Out, In>::run(const ExecutionPtr &execution)
744 746
745 for (auto arg : prevFuture->value()) { 747 for (auto arg : prevFuture->value()) {
746 //We have to manually manage the lifetime of these temporary futures 748 //We have to manually manage the lifetime of these temporary futures
747 Async::Future<Out> *future = new Async::Future<Out>(); 749 KAsync::Future<Out> *future = new KAsync::Future<Out>();
748 EachExecutor<PrevOut, Out, In>::mFunc(arg, *future); 750 EachExecutor<PrevOut, Out, In>::mFunc(arg, *future);
749 auto fw = new Async::FutureWatcher<Out>(); 751 auto fw = new KAsync::FutureWatcher<Out>();
750 mFutureWatchers.append(fw); 752 mFutureWatchers.append(fw);
751 QObject::connect(fw, &Async::FutureWatcher<Out>::futureReady, 753 QObject::connect(fw, &KAsync::FutureWatcher<Out>::futureReady,
752 [out, fw, this, future]() { 754 [out, fw, this, future]() {
753 assert(fw->future().isFinished()); 755 assert(fw->future().isFinished());
754 const int index = mFutureWatchers.indexOf(fw); 756 const int index = mFutureWatchers.indexOf(fw);
755 assert(index > -1); 757 assert(index > -1);
756 mFutureWatchers.removeAt(index); 758 mFutureWatchers.removeAt(index);
757 Async::detail::aggregateFutureValue<Out>(fw->future(), *out); 759 KAsync::detail::aggregateFutureValue<Out>(fw->future(), *out);
758 if (mFutureWatchers.isEmpty()) { 760 if (mFutureWatchers.isEmpty()) {
759 out->setFinished(); 761 out->setFinished();
760 } 762 }
@@ -794,19 +796,19 @@ void SyncThenExecutor<Out, In ...>::run(const ExecutionPtr &execution)
794template<typename Out, typename ... In> 796template<typename Out, typename ... In>
795void SyncThenExecutor<Out, In ...>::run(const ExecutionPtr &execution, std::false_type) 797void SyncThenExecutor<Out, In ...>::run(const ExecutionPtr &execution, std::false_type)
796{ 798{
797 Async::Future<typename detail::prevOut<In ...>::type> *prevFuture = 799 KAsync::Future<typename detail::prevOut<In ...>::type> *prevFuture =
798 execution->prevExecution 800 execution->prevExecution
799 ? execution->prevExecution->result<typename detail::prevOut<In ...>::type>() 801 ? execution->prevExecution->result<typename detail::prevOut<In ...>::type>()
800 : nullptr; 802 : nullptr;
801 (void) prevFuture; // silence 'set but not used' warning 803 (void) prevFuture; // silence 'set but not used' warning
802 Async::Future<Out> *future = execution->result<Out>(); 804 KAsync::Future<Out> *future = execution->result<Out>();
803 future->setValue(SyncThenExecutor<Out, In...>::mFunc(prevFuture ? prevFuture->value() : In() ...)); 805 future->setValue(SyncThenExecutor<Out, In...>::mFunc(prevFuture ? prevFuture->value() : In() ...));
804} 806}
805 807
806template<typename Out, typename ... In> 808template<typename Out, typename ... In>
807void SyncThenExecutor<Out, In ...>::run(const ExecutionPtr &execution, std::true_type) 809void SyncThenExecutor<Out, In ...>::run(const ExecutionPtr &execution, std::true_type)
808{ 810{
809 Async::Future<typename detail::prevOut<In ...>::type> *prevFuture = 811 KAsync::Future<typename detail::prevOut<In ...>::type> *prevFuture =
810 execution->prevExecution 812 execution->prevExecution
811 ? execution->prevExecution->result<typename detail::prevOut<In ...>::type>() 813 ? execution->prevExecution->result<typename detail::prevOut<In ...>::type>()
812 : nullptr; 814 : nullptr;
@@ -842,13 +844,13 @@ void SyncEachExecutor<PrevOut, Out, In>::run(const ExecutionPtr &execution)
842} 844}
843 845
844template<typename PrevOut, typename Out, typename In> 846template<typename PrevOut, typename Out, typename In>
845void SyncEachExecutor<PrevOut, Out, In>::run(Async::Future<Out> *out, const typename PrevOut::value_type &arg, std::false_type) 847void SyncEachExecutor<PrevOut, Out, In>::run(KAsync::Future<Out> *out, const typename PrevOut::value_type &arg, std::false_type)
846{ 848{
847 out->setValue(out->value() + SyncEachExecutor<PrevOut, Out, In>::mFunc(arg)); 849 out->setValue(out->value() + SyncEachExecutor<PrevOut, Out, In>::mFunc(arg));
848} 850}
849 851
850template<typename PrevOut, typename Out, typename In> 852template<typename PrevOut, typename Out, typename In>
851void SyncEachExecutor<PrevOut, Out, In>::run(Async::Future<Out> * /* unused */, const typename PrevOut::value_type &arg, std::true_type) 853void SyncEachExecutor<PrevOut, Out, In>::run(KAsync::Future<Out> * /* unused */, const typename PrevOut::value_type &arg, std::true_type)
852{ 854{
853 SyncEachExecutor<PrevOut, Out, In>::mFunc(arg); 855 SyncEachExecutor<PrevOut, Out, In>::mFunc(arg);
854} 856}
@@ -863,10 +865,10 @@ SyncReduceExecutor<Out, In>::SyncReduceExecutor(SyncReduceTask<Out, In> reduce,
863 865
864} // namespace Private 866} // namespace Private
865 867
866} // namespace Async 868} // namespace KAsync
867 869
868 870
869 871
870#endif // ASYNC_H 872#endif // KASYNC_H
871 873
872 874
diff --git a/async/src/async_impl.h b/async/src/async_impl.h
index 8c74193..5b4e393 100644
--- a/async/src/async_impl.h
+++ b/async/src/async_impl.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2014 Daniel Vrátil <dvratil@redhat.com> 2 * Copyright 2014 - 2015 Daniel Vrátil <dvratil@redhat.com>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public License as 5 * modify it under the terms of the GNU Library General Public License as
@@ -15,13 +15,13 @@
15 * along with this library. If not, see <http://www.gnu.org/licenses/>. 15 * along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18#ifndef ASYNC_IMPL_H 18#ifndef KASYNC_IMPL_H
19#define ASYNC_IMPL_H 19#define KASYNC_IMPL_H
20 20
21#include "async.h" 21#include "async.h"
22#include <type_traits> 22#include <type_traits>
23 23
24namespace Async { 24namespace KAsync {
25 25
26namespace detail { 26namespace detail {
27 27
@@ -48,34 +48,34 @@ struct prevOut {
48 48
49template<typename T> 49template<typename T>
50inline typename std::enable_if<!std::is_void<T>::value, void>::type 50inline typename std::enable_if<!std::is_void<T>::value, void>::type
51copyFutureValue(const Async::Future<T> &in, Async::Future<T> &out) 51copyFutureValue(const KAsync::Future<T> &in, KAsync::Future<T> &out)
52{ 52{
53 out.setValue(in.value()); 53 out.setValue(in.value());
54} 54}
55 55
56template<typename T> 56template<typename T>
57inline typename std::enable_if<std::is_void<T>::value, void>::type 57inline typename std::enable_if<std::is_void<T>::value, void>::type
58copyFutureValue(const Async::Future<T> &in, Async::Future<T> &out) 58copyFutureValue(const KAsync::Future<T> &in, KAsync::Future<T> &out)
59{ 59{
60 // noop 60 // noop
61} 61}
62 62
63template<typename T> 63template<typename T>
64inline typename std::enable_if<!std::is_void<T>::value, void>::type 64inline typename std::enable_if<!std::is_void<T>::value, void>::type
65aggregateFutureValue(const Async::Future<T> &in, Async::Future<T> &out) 65aggregateFutureValue(const KAsync::Future<T> &in, KAsync::Future<T> &out)
66{ 66{
67 out.setValue(out.value() + in.value()); 67 out.setValue(out.value() + in.value());
68} 68}
69 69
70template<typename T> 70template<typename T>
71inline typename std::enable_if<std::is_void<T>::value, void>::type 71inline typename std::enable_if<std::is_void<T>::value, void>::type
72aggregateFutureValue(const Async::Future<T> &in, Async::Future<T> &out) 72aggregateFutureValue(const KAsync::Future<T> &in, KAsync::Future<T> &out)
73{ 73{
74 // noop 74 // noop
75} 75}
76 76
77} // namespace Detail 77} // namespace Detail
78 78
79} // namespace Async 79} // namespace KAsync
80 80
81#endif // ASYNC_IMPL_H 81#endif // KASYNC_IMPL_H
diff --git a/async/src/debug.cpp b/async/src/debug.cpp
index fdf2fa1..64a3a3b 100644
--- a/async/src/debug.cpp
+++ b/async/src/debug.cpp
@@ -25,7 +25,7 @@
25#include <memory> 25#include <memory>
26#endif 26#endif
27 27
28namespace Async 28namespace KAsync
29{ 29{
30 30
31Q_LOGGING_CATEGORY(Debug, "org.kde.async", QtWarningMsg); 31Q_LOGGING_CATEGORY(Debug, "org.kde.async", QtWarningMsg);
@@ -37,15 +37,15 @@ QString demangleName(const char *name)
37 int status = 1; // uses -3 to 0 error codes 37 int status = 1; // uses -3 to 0 error codes
38 std::unique_ptr<char, void(*)(void*)> demangled(abi::__cxa_demangle(name, 0, 0, &status), std::free); 38 std::unique_ptr<char, void(*)(void*)> demangled(abi::__cxa_demangle(name, 0, 0, &status), std::free);
39 if (status == 0) { 39 if (status == 0) {
40 return QString(demangled.get()); 40 return QString::fromLatin1(demangled.get());
41 } 41 }
42#endif 42#endif
43 return QString(name); 43 return QString::fromLatin1(name);
44} 44}
45 45
46} 46}
47 47
48using namespace Async; 48using namespace KAsync;
49 49
50int Tracer::lastId = 0; 50int Tracer::lastId = 0;
51 51
@@ -53,12 +53,12 @@ Tracer::Tracer(Private::Execution *execution)
53 : mId(lastId++) 53 : mId(lastId++)
54 , mExecution(execution) 54 , mExecution(execution)
55{ 55{
56 msg(Async::Tracer::Start); 56 msg(KAsync::Tracer::Start);
57} 57}
58 58
59Tracer::~Tracer() 59Tracer::~Tracer()
60{ 60{
61 msg(Async::Tracer::End); 61 msg(KAsync::Tracer::End);
62 // FIXME: Does this work on parallel executions? 62 // FIXME: Does this work on parallel executions?
63 --lastId; 63 --lastId;
64 --mId; 64 --mId;
@@ -68,8 +68,8 @@ void Tracer::msg(Tracer::MsgType msgType)
68{ 68{
69#ifndef QT_NO_DEBUG 69#ifndef QT_NO_DEBUG
70 qCDebug(Trace).nospace() << (QString().fill(QLatin1Char(' '), mId * 2) % 70 qCDebug(Trace).nospace() << (QString().fill(QLatin1Char(' '), mId * 2) %
71 (msgType == Async::Tracer::Start ? " START " : " END ") % 71 (msgType == KAsync::Tracer::Start ? QStringLiteral(" START ") : QStringLiteral(" END ")) %
72 QString::number(mId) % " " % 72 QString::number(mId) % QStringLiteral(" ") %
73 mExecution->executor->mExecutorName); 73 mExecution->executor->mExecutorName);
74#endif 74#endif
75} 75}
diff --git a/async/src/debug.h b/async/src/debug.h
index c453eb3..b2b2ff7 100644
--- a/async/src/debug.h
+++ b/async/src/debug.h
@@ -15,8 +15,10 @@
15 * along with this library. If not, see <http://www.gnu.org/licenses/>. 15 * along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18#ifndef ASYNC_DEBUG_H 18#ifndef KASYNC_DEBUG_H
19#define ASYNC_DEBUG_H 19#define KASYNC_DEBUG_H
20
21#include "kasync_export.h"
20 22
21#include <QLoggingCategory> 23#include <QLoggingCategory>
22#include <QStringBuilder> 24#include <QStringBuilder>
@@ -25,20 +27,20 @@
25#include <typeinfo> 27#include <typeinfo>
26#endif 28#endif
27 29
28namespace Async 30namespace KAsync
29{ 31{
30 32
31Q_DECLARE_LOGGING_CATEGORY(Debug) 33Q_DECLARE_LOGGING_CATEGORY(Debug)
32Q_DECLARE_LOGGING_CATEGORY(Trace) 34Q_DECLARE_LOGGING_CATEGORY(Trace)
33 35
34QString demangleName(const char *name); 36KASYNC_EXPORT QString demangleName(const char *name);
35 37
36namespace Private 38namespace Private
37{ 39{
38class Execution; 40class Execution;
39} 41}
40 42
41class Tracer 43class KASYNC_EXPORT Tracer
42{ 44{
43public: 45public:
44 Tracer(Private::Execution *execution); 46 Tracer(Private::Execution *execution);
@@ -62,7 +64,7 @@ private:
62#ifndef QT_NO_DEBUG 64#ifndef QT_NO_DEBUG
63 template<typename T> 65 template<typename T>
64 QString storeExecutorNameExpanded() { 66 QString storeExecutorNameExpanded() {
65 return Async::demangleName(typeid(T).name()); 67 return KAsync::demangleName(typeid(T).name());
66 } 68 }
67 69
68 template<typename T, typename ... Tail> 70 template<typename T, typename ... Tail>
@@ -77,4 +79,4 @@ private:
77 #define STORE_EXECUTOR_NAME(...) 79 #define STORE_EXECUTOR_NAME(...)
78#endif 80#endif
79 81
80#endif // ASYNC_DEBUG_H \ No newline at end of file 82#endif // KASYNC_DEBUG_H \ No newline at end of file
diff --git a/async/src/future.cpp b/async/src/future.cpp
index 4f3cd80..9281cc8 100644
--- a/async/src/future.cpp
+++ b/async/src/future.cpp
@@ -18,7 +18,7 @@
18#include "future.h" 18#include "future.h"
19#include "async.h" 19#include "async.h"
20 20
21using namespace Async; 21using namespace KAsync;
22 22
23FutureBase::PrivateBase::PrivateBase(const Private::ExecutionPtr &execution) 23FutureBase::PrivateBase::PrivateBase(const Private::ExecutionPtr &execution)
24 : finished(false) 24 : finished(false)
@@ -53,7 +53,7 @@ FutureBase::FutureBase(FutureBase::PrivateBase *dd)
53{ 53{
54} 54}
55 55
56FutureBase::FutureBase(const Async::FutureBase &other) 56FutureBase::FutureBase(const KAsync::FutureBase &other)
57 : d(other.d) 57 : d(other.d)
58{ 58{
59} 59}
diff --git a/async/src/future.h b/async/src/future.h
index ff199ef..b2b723e 100644
--- a/async/src/future.h
+++ b/async/src/future.h
@@ -18,6 +18,8 @@
18#ifndef FUTURE_H 18#ifndef FUTURE_H
19#define FUTURE_H 19#define FUTURE_H
20 20
21#include "kasync_export.h"
22
21class QEventLoop; 23class QEventLoop;
22 24
23#include <type_traits> 25#include <type_traits>
@@ -27,7 +29,7 @@ class QEventLoop;
27#include <QVector> 29#include <QVector>
28#include <QEventLoop> 30#include <QEventLoop>
29 31
30namespace Async { 32namespace KAsync {
31 33
32class FutureWatcherBase; 34class FutureWatcherBase;
33template<typename T> 35template<typename T>
@@ -40,9 +42,9 @@ class ExecutorBase;
40typedef QSharedPointer<Execution> ExecutionPtr; 42typedef QSharedPointer<Execution> ExecutionPtr;
41} // namespace Private 43} // namespace Private
42 44
43class FutureBase 45class KASYNC_EXPORT FutureBase
44{ 46{
45 friend class Async::Private::Execution; 47 friend class KAsync::Private::Execution;
46 friend class FutureWatcherBase; 48 friend class FutureWatcherBase;
47 49
48public: 50public:
@@ -61,7 +63,7 @@ protected:
61 class PrivateBase : public QSharedData 63 class PrivateBase : public QSharedData
62 { 64 {
63 public: 65 public:
64 PrivateBase(const Async::Private::ExecutionPtr &execution); 66 PrivateBase(const KAsync::Private::ExecutionPtr &execution);
65 virtual ~PrivateBase(); 67 virtual ~PrivateBase();
66 68
67 void releaseExecution(); 69 void releaseExecution();
@@ -72,14 +74,14 @@ protected:
72 74
73 QVector<QPointer<FutureWatcherBase>> watchers; 75 QVector<QPointer<FutureWatcherBase>> watchers;
74 private: 76 private:
75 QWeakPointer<Async::Private::Execution> mExecution; 77 QWeakPointer<KAsync::Private::Execution> mExecution;
76 }; 78 };
77 79
78 FutureBase(); 80 FutureBase();
79 FutureBase(FutureBase::PrivateBase *dd); 81 FutureBase(FutureBase::PrivateBase *dd);
80 FutureBase(const FutureBase &other); 82 FutureBase(const FutureBase &other);
81 83
82 void addWatcher(Async::FutureWatcherBase *watcher); 84 void addWatcher(KAsync::FutureWatcherBase *watcher);
83 void releaseExecution(); 85 void releaseExecution();
84 86
85protected: 87protected:
@@ -105,14 +107,14 @@ public:
105 } 107 }
106 FutureWatcher<T> watcher; 108 FutureWatcher<T> watcher;
107 QEventLoop eventLoop; 109 QEventLoop eventLoop;
108 QObject::connect(&watcher, &Async::FutureWatcher<T>::futureReady, 110 QObject::connect(&watcher, &KAsync::FutureWatcher<T>::futureReady,
109 &eventLoop, &QEventLoop::quit); 111 &eventLoop, &QEventLoop::quit);
110 watcher.setFuture(*static_cast<const Async::Future<T>*>(this)); 112 watcher.setFuture(*static_cast<const KAsync::Future<T>*>(this));
111 eventLoop.exec(); 113 eventLoop.exec();
112 } 114 }
113 115
114protected: 116protected:
115 FutureGeneric(const Async::Private::ExecutionPtr &execution) 117 FutureGeneric(const KAsync::Private::ExecutionPtr &execution)
116 : FutureBase(new Private(execution)) 118 : FutureBase(new Private(execution))
117 {} 119 {}
118 120
@@ -124,7 +126,7 @@ protected:
124 class Private : public FutureBase::PrivateBase 126 class Private : public FutureBase::PrivateBase
125 { 127 {
126 public: 128 public:
127 Private(const Async::Private::ExecutionPtr &execution) 129 Private(const KAsync::Private::ExecutionPtr &execution)
128 : FutureBase::PrivateBase(execution) 130 : FutureBase::PrivateBase(execution)
129 {} 131 {}
130 132
@@ -137,14 +139,14 @@ protected:
137template<typename T> 139template<typename T>
138class Future : public FutureGeneric<T> 140class Future : public FutureGeneric<T>
139{ 141{
140 friend class Async::Private::ExecutorBase; 142 friend class KAsync::Private::ExecutorBase;
141 143
142 template<typename T_> 144 template<typename T_>
143 friend class Async::FutureWatcher; 145 friend class KAsync::FutureWatcher;
144 146
145public: 147public:
146 Future() 148 Future()
147 : FutureGeneric<T>(Async::Private::ExecutionPtr()) 149 : FutureGeneric<T>(KAsync::Private::ExecutionPtr())
148 {} 150 {}
149 151
150 Future(const Future<T> &other) 152 Future(const Future<T> &other)
@@ -162,7 +164,7 @@ public:
162 } 164 }
163 165
164protected: 166protected:
165 Future(const Async::Private::ExecutionPtr &execution) 167 Future(const KAsync::Private::ExecutionPtr &execution)
166 : FutureGeneric<T>(execution) 168 : FutureGeneric<T>(execution)
167 {} 169 {}
168 170
@@ -171,11 +173,11 @@ protected:
171template<> 173template<>
172class Future<void> : public FutureGeneric<void> 174class Future<void> : public FutureGeneric<void>
173{ 175{
174 friend class Async::Private::ExecutorBase; 176 friend class KAsync::Private::ExecutorBase;
175 177
176public: 178public:
177 Future() 179 Future()
178 : FutureGeneric<void>(Async::Private::ExecutionPtr()) 180 : FutureGeneric<void>(KAsync::Private::ExecutionPtr())
179 {} 181 {}
180 182
181 Future(const Future<void> &other) 183 Future(const Future<void> &other)
@@ -183,7 +185,7 @@ public:
183 {} 185 {}
184 186
185protected: 187protected:
186 Future(const Async::Private::ExecutionPtr &execution) 188 Future(const KAsync::Private::ExecutionPtr &execution)
187 : FutureGeneric<void>(execution) 189 : FutureGeneric<void>(execution)
188 {} 190 {}
189}; 191};
@@ -192,7 +194,7 @@ protected:
192 194
193 195
194 196
195class FutureWatcherBase : public QObject 197class KASYNC_EXPORT FutureWatcherBase : public QObject
196{ 198{
197 Q_OBJECT 199 Q_OBJECT
198 200
@@ -209,12 +211,12 @@ protected:
209 void futureReadyCallback(); 211 void futureReadyCallback();
210 void futureProgressCallback(qreal progress); 212 void futureProgressCallback(qreal progress);
211 213
212 void setFutureImpl(const Async::FutureBase &future); 214 void setFutureImpl(const KAsync::FutureBase &future);
213 215
214protected: 216protected:
215 class Private { 217 class Private {
216 public: 218 public:
217 Async::FutureBase future; 219 KAsync::FutureBase future;
218 }; 220 };
219 221
220 Private * const d; 222 Private * const d;
@@ -226,7 +228,7 @@ private:
226template<typename T> 228template<typename T>
227class FutureWatcher : public FutureWatcherBase 229class FutureWatcher : public FutureWatcherBase
228{ 230{
229 friend class Async::FutureGeneric<T>; 231 friend class KAsync::FutureGeneric<T>;
230 232
231public: 233public:
232 FutureWatcher(QObject *parent = nullptr) 234 FutureWatcher(QObject *parent = nullptr)
@@ -236,14 +238,14 @@ public:
236 ~FutureWatcher() 238 ~FutureWatcher()
237 {} 239 {}
238 240
239 void setFuture(const Async::Future<T> &future) 241 void setFuture(const KAsync::Future<T> &future)
240 { 242 {
241 setFutureImpl(*static_cast<const Async::FutureBase*>(&future)); 243 setFutureImpl(*static_cast<const KAsync::FutureBase*>(&future));
242 } 244 }
243 245
244 Async::Future<T> future() const 246 KAsync::Future<T> future() const
245 { 247 {
246 return *static_cast<Async::Future<T>*>(&d->future); 248 return *static_cast<KAsync::Future<T>*>(&d->future);
247 } 249 }
248 250
249private: 251private: