From 5b78e0da1d64b6096829f54b29f14ec5643b5ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Fri, 15 May 2015 16:00:32 +0200 Subject: Async: rename Async namespace to KAsync --- async/src/async.cpp | 18 +++---- async/src/async.h | 134 +++++++++++++++++++++++++------------------------ async/src/async_impl.h | 20 ++++---- async/src/debug.cpp | 16 +++--- async/src/debug.h | 16 +++--- async/src/future.cpp | 4 +- async/src/future.h | 52 ++++++++++--------- 7 files changed, 133 insertions(+), 127 deletions(-) (limited to 'async/src') 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 @@ #include #include -using namespace Async; +using namespace KAsync; Private::Execution::Execution(const Private::ExecutorBasePtr &executor) : executor(executor) @@ -104,11 +104,11 @@ static void asyncWhile(const std::function)> &bod }); } -Job Async::dowhile(Condition condition, ThenTask body) +Job KAsync::dowhile(Condition condition, ThenTask body) { - return Async::start([body, condition](Async::Future &future) { + return KAsync::start([body, condition](KAsync::Future &future) { asyncWhile([condition, body](std::function whileCallback) { - Async::start(body).then([whileCallback, condition]() { + KAsync::start(body).then([whileCallback, condition]() { whileCallback(!condition()); }).exec(); }, @@ -118,11 +118,11 @@ Job Async::dowhile(Condition condition, ThenTask body) }); } -Job Async::dowhile(ThenTask body) +Job KAsync::dowhile(ThenTask body) { - return Async::start([body](Async::Future &future) { + return KAsync::start([body](KAsync::Future &future) { asyncWhile([body](std::function whileCallback) { - Async::start(body).then([whileCallback](bool result) { + KAsync::start(body).then([whileCallback](bool result) { whileCallback(!result); //FIXME this return value is only required because .then doesn't work return true; @@ -134,10 +134,10 @@ Job Async::dowhile(ThenTask body) }); } -Job Async::wait(int delay) +Job KAsync::wait(int delay) { auto timer = QSharedPointer::create(); - return Async::start([timer, delay](Async::Future &future) { + return KAsync::start([timer, delay](KAsync::Future &future) { timer->setSingleShot(true); QObject::connect(timer.data(), &QTimer::timeout, [&future]() { 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 @@ /* - * Copyright 2014 Daniel Vrátil + * Copyright 2014 - 2015 Daniel Vrátil * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License as @@ -15,8 +15,10 @@ * along with this library. If not, see . */ -#ifndef ASYNC_H -#define ASYNC_H +#ifndef KASYNC_H +#define KASYNC_H + +#include "kasync_export.h" #include #include @@ -64,7 +66,7 @@ * TODO: Possibility to abort a job through future (perhaps optional?) * TODO: Support for timeout, specified during exec call, after which the error handler gets called with a defined errorCode. */ -namespace Async { +namespace KAsync { template class Executor; @@ -75,15 +77,15 @@ template class Job; template -using ThenTask = typename detail::identity&)>>::type; +using ThenTask = typename detail::identity&)>>::type; template using SyncThenTask = typename detail::identity>::type; template -using EachTask = typename detail::identity&)>>::type; +using EachTask = typename detail::identity&)>>::type; template using SyncEachTask = typename detail::identity>::type; template -using ReduceTask = typename detail::identity&)>>::type; +using ReduceTask = typename detail::identity&)>>::type; template using SyncReduceTask = typename detail::identity>::type; @@ -96,15 +98,15 @@ namespace Private class ExecutorBase; typedef QSharedPointer ExecutorBasePtr; -struct Execution { +struct KASYNC_EXPORT Execution { Execution(const ExecutorBasePtr &executor); ~Execution(); void setFinished(); template - Async::Future* result() const + KAsync::Future* result() const { - return static_cast*>(resultBase); + return static_cast*>(resultBase); } void releaseFuture(); @@ -125,16 +127,16 @@ struct Execution { typedef QSharedPointer ExecutionPtr; -class ExecutorBase +class KASYNC_EXPORT ExecutorBase { template friend class Executor; template - friend class Async::Job; + friend class KAsync::Job; friend class Execution; - friend class Async::Tracer; + friend class KAsync::Tracer; public: virtual ~ExecutorBase(); @@ -144,7 +146,7 @@ protected: ExecutorBase(const ExecutorBasePtr &parent); template - Async::Future* createFuture(const ExecutionPtr &execution) const; + KAsync::Future* createFuture(const ExecutionPtr &execution) const; virtual bool hasErrorFunc() const = 0; virtual bool handleError(const ExecutionPtr &execution) = 0; @@ -193,7 +195,7 @@ public: void run(const ExecutionPtr &execution); private: EachTask mFunc; - QVector*> mFutureWatchers; + QVector*> mFutureWatchers; }; template @@ -234,8 +236,8 @@ public: SyncEachExecutor(SyncEachTask each, ErrorHandler errorFunc, const ExecutorBasePtr &parent); void run(const ExecutionPtr &execution); private: - void run(Async::Future *future, const typename PrevOut::value_type &arg, std::false_type); // !std::is_void - void run(Async::Future *future, const typename PrevOut::value_type &arg, std::true_type); // std::is_void + void run(KAsync::Future *future, const typename PrevOut::value_type &arg, std::false_type); // !std::is_void + void run(KAsync::Future *future, const typename PrevOut::value_type &arg, std::true_type); // std::is_void SyncEachTask mFunc; }; @@ -244,11 +246,11 @@ private: /** * Start an asynchronous job sequence. * - * Async::start() is your starting point to build a chain of jobs to be executed + * KAsync::start() is your starting point to build a chain of jobs to be executed * asynchronously. * * @param func An asynchronous function to be executed. The function must have - * void return type, and accept exactly one argument of type @p Async::Future, + * void return type, and accept exactly one argument of type @p KAsync::Future, * where @p In is type of the result. */ template @@ -267,14 +269,14 @@ Job start(); * * The loop continues while @param condition returns true. */ -Job dowhile(Condition condition, ThenTask func); +KASYNC_EXPORT Job dowhile(Condition condition, ThenTask func); /** * Async while loop. * * Loop continues while body returns true. */ -Job dowhile(ThenTask body); +KASYNC_EXPORT Job dowhile(ThenTask body); /** * Iterate over a container. @@ -287,7 +289,7 @@ Job iterate(const Out &container); /** * Async delay. */ -Job wait(int delay); +KASYNC_EXPORT Job wait(int delay); /** * A null job. @@ -307,7 +309,7 @@ Job null(); template Job error(int errorCode = 1, const QString &errorMessage = QString()); -class JobBase +class KASYNC_EXPORT JobBase { template friend class Job; @@ -324,18 +326,18 @@ protected: * An Asynchronous job * * A single instance of Job represents a single method that will be executed - * asynchrously. The Job is started by @p Job::exec(), which returns @p Async::Future + * asynchrously. The Job is started by @p Job::exec(), which returns @p KAsync::Future * immediatelly. The Future will be set to finished state once the asynchronous - * task has finished. You can use @p Async::Future::waitForFinished() to wait for + * task has finished. You can use @p KAsync::Future::waitForFinished() to wait for * for the Future in blocking manner. * * It is possible to chain multiple Jobs one after another in different fashion * (sequential, parallel, etc.). Calling Job::exec() will then return a pending - * @p Async::Future, and will execute the entire chain of jobs. + * @p KAsync::Future, and will execute the entire chain of jobs. * * @code * auto job = Job::start>( - * [](Async::Future> &future) { + * [](KAsync::Future> &future) { * MyREST::PendingUsers *pu = MyREST::requestListOfUsers(); * QObject::connect(pu, &PendingOperation::finished, * [&](PendingOperation *pu) { @@ -344,7 +346,7 @@ protected: * }); * }) * .each, int>( - * [](const int &userId, Async::Future> &future) { + * [](const int &userId, KAsync::Future> &future) { * MyREST::PendingUser *pu = MyREST::requestUserDetails(userId); * QObject::connect(pu, &PendingOperation::finished, * [&](PendingOperation *pu) { @@ -353,7 +355,7 @@ protected: * }); * }); * - * Async::Future> usersFuture = job.exec(); + * KAsync::Future> usersFuture = job.exec(); * usersFuture.waitForFinished(); * QList users = usersFuture.value(); * @endcode @@ -369,10 +371,10 @@ class Job : public JobBase friend class Job; template - friend Job start(Async::ThenTask func, ErrorHandler errorFunc); + friend Job start(KAsync::ThenTask func, ErrorHandler errorFunc); template - friend Job start(Async::SyncThenTask func, ErrorHandler errorFunc); + friend Job start(KAsync::SyncThenTask func, ErrorHandler errorFunc); #ifdef WITH_KJOB template @@ -454,7 +456,7 @@ public: } template - Async::Future exec(FirstIn in) + KAsync::Future exec(FirstIn in) { // Inject a fake sync executor that will return the initial value Private::ExecutorBasePtr first = mExecutor; @@ -474,10 +476,10 @@ public: return result; } - Async::Future exec() + KAsync::Future exec() { Private::ExecutionPtr execution = mExecutor->exec(mExecutor); - Async::Future result = *execution->result(); + KAsync::Future result = *execution->result(); return result; } @@ -499,15 +501,15 @@ private: template void reduceInvariants() { - static_assert(Async::detail::isIterable::value, + static_assert(KAsync::detail::isIterable::value, "The 'Result' task can only be connected to a job that returns a list or an array"); static_assert(std::is_same::value, "The return type of previous task must be compatible with input type of this task"); } template - inline std::function&)> nestedJobWrapper(Job otherJob) { - return [otherJob](InOther ... in, Async::Future &future) { + inline std::function&)> nestedJobWrapper(Job otherJob) { + return [otherJob](InOther ... in, KAsync::Future &future) { // copy by value is const auto job = otherJob; FutureWatcher *watcher = new FutureWatcher(); @@ -518,7 +520,7 @@ private: // in copyFutureValue() // copy by value is const auto outFuture = future; - Async::detail::copyFutureValue(watcher->future(), outFuture); + KAsync::detail::copyFutureValue(watcher->future(), outFuture); if (watcher->future().errorCode()) { outFuture.setError(watcher->future().errorCode(), watcher->future().errorMessage()); } else { @@ -531,12 +533,12 @@ private: } }; -} // namespace Async +} // namespace KAsync // ********** Out of line definitions **************** -namespace Async { +namespace KAsync { template Job start(ThenTask func, ErrorHandler error) @@ -557,7 +559,7 @@ template start() { return Job(Private::ExecutorBasePtr( - new Private::ThenExecutor([](const Args & ... args, Async::Future &future) + new Private::ThenExecutor([](const Args & ... args, KAsync::Future &future) { KJobType *job = new KJobType(args ...); job->connect(job, &KJob::finished, @@ -578,8 +580,8 @@ Job start() template Job null() { - return Async::start( - [](Async::Future &future) { + return KAsync::start( + [](KAsync::Future &future) { future.setFinished(); }); } @@ -587,8 +589,8 @@ Job null() template Job error(int errorCode, const QString &errorMessage) { - return Async::start( - [errorCode, errorMessage](Async::Future &future) { + return KAsync::start( + [errorCode, errorMessage](KAsync::Future &future) { future.setError(errorCode, errorMessage); }); } @@ -596,7 +598,7 @@ Job error(int errorCode, const QString &errorMessage) template Job iterate(const Out &container) { - return Async::start( + return KAsync::start( [container]() { return container; }); @@ -606,9 +608,9 @@ Job iterate(const Out &container) namespace Private { template -Async::Future* ExecutorBase::createFuture(const ExecutionPtr &execution) const +KAsync::Future* ExecutorBase::createFuture(const ExecutionPtr &execution) const { - return new Async::Future(execution); + return new KAsync::Future(execution); } template @@ -625,8 +627,8 @@ ExecutionPtr Executor::exec(const ExecutorBasePtr &self) execution->prevExecution = mPrev ? mPrev->exec(mPrev) : ExecutionPtr(); execution->resultBase = ExecutorBase::createFuture(execution); - auto fw = new Async::FutureWatcher(); - QObject::connect(fw, &Async::FutureWatcher::futureReady, + auto fw = new KAsync::FutureWatcher(); + QObject::connect(fw, &KAsync::FutureWatcher::futureReady, [fw, execution, this]() { handleError(execution); execution->setFinished(); @@ -634,7 +636,7 @@ ExecutionPtr Executor::exec(const ExecutorBasePtr &self) }); fw->setFuture(*execution->result()); - Async::Future *prevFuture = execution->prevExecution ? execution->prevExecution->result() : nullptr; + KAsync::Future *prevFuture = execution->prevExecution ? execution->prevExecution->result() : nullptr; if (!prevFuture || prevFuture->isFinished()) { if (prevFuture) { // prevFuture implies execution->prevExecution if (prevFuture->errorCode()) { @@ -655,8 +657,8 @@ ExecutionPtr Executor::exec(const ExecutorBasePtr &self) execution->isRunning = true; run(execution); } else { - auto prevFutureWatcher = new Async::FutureWatcher(); - QObject::connect(prevFutureWatcher, &Async::FutureWatcher::futureReady, + auto prevFutureWatcher = new KAsync::FutureWatcher(); + QObject::connect(prevFutureWatcher, &KAsync::FutureWatcher::futureReady, [prevFutureWatcher, execution, this]() { auto prevFuture = prevFutureWatcher->future(); assert(prevFuture.isFinished()); @@ -679,7 +681,7 @@ ExecutionPtr Executor::exec(const ExecutorBasePtr &self) run(execution); }); - prevFutureWatcher->setFuture(*static_cast*>(prevFuture)); + prevFutureWatcher->setFuture(*static_cast*>(prevFuture)); } return execution; @@ -712,7 +714,7 @@ ThenExecutor::ThenExecutor(ThenTask then, ErrorHandler template void ThenExecutor::run(const ExecutionPtr &execution) { - Async::Future::type> *prevFuture = nullptr; + KAsync::Future::type> *prevFuture = nullptr; if (execution->prevExecution) { prevFuture = execution->prevExecution->result::type>(); assert(prevFuture->isFinished()); @@ -744,17 +746,17 @@ void EachExecutor::run(const ExecutionPtr &execution) for (auto arg : prevFuture->value()) { //We have to manually manage the lifetime of these temporary futures - Async::Future *future = new Async::Future(); + KAsync::Future *future = new KAsync::Future(); EachExecutor::mFunc(arg, *future); - auto fw = new Async::FutureWatcher(); + auto fw = new KAsync::FutureWatcher(); mFutureWatchers.append(fw); - QObject::connect(fw, &Async::FutureWatcher::futureReady, + QObject::connect(fw, &KAsync::FutureWatcher::futureReady, [out, fw, this, future]() { assert(fw->future().isFinished()); const int index = mFutureWatchers.indexOf(fw); assert(index > -1); mFutureWatchers.removeAt(index); - Async::detail::aggregateFutureValue(fw->future(), *out); + KAsync::detail::aggregateFutureValue(fw->future(), *out); if (mFutureWatchers.isEmpty()) { out->setFinished(); } @@ -794,19 +796,19 @@ void SyncThenExecutor::run(const ExecutionPtr &execution) template void SyncThenExecutor::run(const ExecutionPtr &execution, std::false_type) { - Async::Future::type> *prevFuture = + KAsync::Future::type> *prevFuture = execution->prevExecution ? execution->prevExecution->result::type>() : nullptr; (void) prevFuture; // silence 'set but not used' warning - Async::Future *future = execution->result(); + KAsync::Future *future = execution->result(); future->setValue(SyncThenExecutor::mFunc(prevFuture ? prevFuture->value() : In() ...)); } template void SyncThenExecutor::run(const ExecutionPtr &execution, std::true_type) { - Async::Future::type> *prevFuture = + KAsync::Future::type> *prevFuture = execution->prevExecution ? execution->prevExecution->result::type>() : nullptr; @@ -842,13 +844,13 @@ void SyncEachExecutor::run(const ExecutionPtr &execution) } template -void SyncEachExecutor::run(Async::Future *out, const typename PrevOut::value_type &arg, std::false_type) +void SyncEachExecutor::run(KAsync::Future *out, const typename PrevOut::value_type &arg, std::false_type) { out->setValue(out->value() + SyncEachExecutor::mFunc(arg)); } template -void SyncEachExecutor::run(Async::Future * /* unused */, const typename PrevOut::value_type &arg, std::true_type) +void SyncEachExecutor::run(KAsync::Future * /* unused */, const typename PrevOut::value_type &arg, std::true_type) { SyncEachExecutor::mFunc(arg); } @@ -863,10 +865,10 @@ SyncReduceExecutor::SyncReduceExecutor(SyncReduceTask reduce, } // namespace Private -} // namespace Async +} // namespace KAsync -#endif // ASYNC_H +#endif // KASYNC_H 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 @@ /* - * Copyright 2014 Daniel Vrátil + * Copyright 2014 - 2015 Daniel Vrátil * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License as @@ -15,13 +15,13 @@ * along with this library. If not, see . */ -#ifndef ASYNC_IMPL_H -#define ASYNC_IMPL_H +#ifndef KASYNC_IMPL_H +#define KASYNC_IMPL_H #include "async.h" #include -namespace Async { +namespace KAsync { namespace detail { @@ -48,34 +48,34 @@ struct prevOut { template inline typename std::enable_if::value, void>::type -copyFutureValue(const Async::Future &in, Async::Future &out) +copyFutureValue(const KAsync::Future &in, KAsync::Future &out) { out.setValue(in.value()); } template inline typename std::enable_if::value, void>::type -copyFutureValue(const Async::Future &in, Async::Future &out) +copyFutureValue(const KAsync::Future &in, KAsync::Future &out) { // noop } template inline typename std::enable_if::value, void>::type -aggregateFutureValue(const Async::Future &in, Async::Future &out) +aggregateFutureValue(const KAsync::Future &in, KAsync::Future &out) { out.setValue(out.value() + in.value()); } template inline typename std::enable_if::value, void>::type -aggregateFutureValue(const Async::Future &in, Async::Future &out) +aggregateFutureValue(const KAsync::Future &in, KAsync::Future &out) { // noop } } // namespace Detail -} // namespace Async +} // namespace KAsync -#endif // ASYNC_IMPL_H +#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 @@ #include #endif -namespace Async +namespace KAsync { Q_LOGGING_CATEGORY(Debug, "org.kde.async", QtWarningMsg); @@ -37,15 +37,15 @@ QString demangleName(const char *name) int status = 1; // uses -3 to 0 error codes std::unique_ptr demangled(abi::__cxa_demangle(name, 0, 0, &status), std::free); if (status == 0) { - return QString(demangled.get()); + return QString::fromLatin1(demangled.get()); } #endif - return QString(name); + return QString::fromLatin1(name); } } -using namespace Async; +using namespace KAsync; int Tracer::lastId = 0; @@ -53,12 +53,12 @@ Tracer::Tracer(Private::Execution *execution) : mId(lastId++) , mExecution(execution) { - msg(Async::Tracer::Start); + msg(KAsync::Tracer::Start); } Tracer::~Tracer() { - msg(Async::Tracer::End); + msg(KAsync::Tracer::End); // FIXME: Does this work on parallel executions? --lastId; --mId; @@ -68,8 +68,8 @@ void Tracer::msg(Tracer::MsgType msgType) { #ifndef QT_NO_DEBUG qCDebug(Trace).nospace() << (QString().fill(QLatin1Char(' '), mId * 2) % - (msgType == Async::Tracer::Start ? " START " : " END ") % - QString::number(mId) % " " % + (msgType == KAsync::Tracer::Start ? QStringLiteral(" START ") : QStringLiteral(" END ")) % + QString::number(mId) % QStringLiteral(" ") % mExecution->executor->mExecutorName); #endif } 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 @@ * along with this library. If not, see . */ -#ifndef ASYNC_DEBUG_H -#define ASYNC_DEBUG_H +#ifndef KASYNC_DEBUG_H +#define KASYNC_DEBUG_H + +#include "kasync_export.h" #include #include @@ -25,20 +27,20 @@ #include #endif -namespace Async +namespace KAsync { Q_DECLARE_LOGGING_CATEGORY(Debug) Q_DECLARE_LOGGING_CATEGORY(Trace) -QString demangleName(const char *name); +KASYNC_EXPORT QString demangleName(const char *name); namespace Private { class Execution; } -class Tracer +class KASYNC_EXPORT Tracer { public: Tracer(Private::Execution *execution); @@ -62,7 +64,7 @@ private: #ifndef QT_NO_DEBUG template QString storeExecutorNameExpanded() { - return Async::demangleName(typeid(T).name()); + return KAsync::demangleName(typeid(T).name()); } template @@ -77,4 +79,4 @@ private: #define STORE_EXECUTOR_NAME(...) #endif -#endif // ASYNC_DEBUG_H \ No newline at end of file +#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 @@ #include "future.h" #include "async.h" -using namespace Async; +using namespace KAsync; FutureBase::PrivateBase::PrivateBase(const Private::ExecutionPtr &execution) : finished(false) @@ -53,7 +53,7 @@ FutureBase::FutureBase(FutureBase::PrivateBase *dd) { } -FutureBase::FutureBase(const Async::FutureBase &other) +FutureBase::FutureBase(const KAsync::FutureBase &other) : d(other.d) { } 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 @@ #ifndef FUTURE_H #define FUTURE_H +#include "kasync_export.h" + class QEventLoop; #include @@ -27,7 +29,7 @@ class QEventLoop; #include #include -namespace Async { +namespace KAsync { class FutureWatcherBase; template @@ -40,9 +42,9 @@ class ExecutorBase; typedef QSharedPointer ExecutionPtr; } // namespace Private -class FutureBase +class KASYNC_EXPORT FutureBase { - friend class Async::Private::Execution; + friend class KAsync::Private::Execution; friend class FutureWatcherBase; public: @@ -61,7 +63,7 @@ protected: class PrivateBase : public QSharedData { public: - PrivateBase(const Async::Private::ExecutionPtr &execution); + PrivateBase(const KAsync::Private::ExecutionPtr &execution); virtual ~PrivateBase(); void releaseExecution(); @@ -72,14 +74,14 @@ protected: QVector> watchers; private: - QWeakPointer mExecution; + QWeakPointer mExecution; }; FutureBase(); FutureBase(FutureBase::PrivateBase *dd); FutureBase(const FutureBase &other); - void addWatcher(Async::FutureWatcherBase *watcher); + void addWatcher(KAsync::FutureWatcherBase *watcher); void releaseExecution(); protected: @@ -105,14 +107,14 @@ public: } FutureWatcher watcher; QEventLoop eventLoop; - QObject::connect(&watcher, &Async::FutureWatcher::futureReady, + QObject::connect(&watcher, &KAsync::FutureWatcher::futureReady, &eventLoop, &QEventLoop::quit); - watcher.setFuture(*static_cast*>(this)); + watcher.setFuture(*static_cast*>(this)); eventLoop.exec(); } protected: - FutureGeneric(const Async::Private::ExecutionPtr &execution) + FutureGeneric(const KAsync::Private::ExecutionPtr &execution) : FutureBase(new Private(execution)) {} @@ -124,7 +126,7 @@ protected: class Private : public FutureBase::PrivateBase { public: - Private(const Async::Private::ExecutionPtr &execution) + Private(const KAsync::Private::ExecutionPtr &execution) : FutureBase::PrivateBase(execution) {} @@ -137,14 +139,14 @@ protected: template class Future : public FutureGeneric { - friend class Async::Private::ExecutorBase; + friend class KAsync::Private::ExecutorBase; template - friend class Async::FutureWatcher; + friend class KAsync::FutureWatcher; public: Future() - : FutureGeneric(Async::Private::ExecutionPtr()) + : FutureGeneric(KAsync::Private::ExecutionPtr()) {} Future(const Future &other) @@ -162,7 +164,7 @@ public: } protected: - Future(const Async::Private::ExecutionPtr &execution) + Future(const KAsync::Private::ExecutionPtr &execution) : FutureGeneric(execution) {} @@ -171,11 +173,11 @@ protected: template<> class Future : public FutureGeneric { - friend class Async::Private::ExecutorBase; + friend class KAsync::Private::ExecutorBase; public: Future() - : FutureGeneric(Async::Private::ExecutionPtr()) + : FutureGeneric(KAsync::Private::ExecutionPtr()) {} Future(const Future &other) @@ -183,7 +185,7 @@ public: {} protected: - Future(const Async::Private::ExecutionPtr &execution) + Future(const KAsync::Private::ExecutionPtr &execution) : FutureGeneric(execution) {} }; @@ -192,7 +194,7 @@ protected: -class FutureWatcherBase : public QObject +class KASYNC_EXPORT FutureWatcherBase : public QObject { Q_OBJECT @@ -209,12 +211,12 @@ protected: void futureReadyCallback(); void futureProgressCallback(qreal progress); - void setFutureImpl(const Async::FutureBase &future); + void setFutureImpl(const KAsync::FutureBase &future); protected: class Private { public: - Async::FutureBase future; + KAsync::FutureBase future; }; Private * const d; @@ -226,7 +228,7 @@ private: template class FutureWatcher : public FutureWatcherBase { - friend class Async::FutureGeneric; + friend class KAsync::FutureGeneric; public: FutureWatcher(QObject *parent = nullptr) @@ -236,14 +238,14 @@ public: ~FutureWatcher() {} - void setFuture(const Async::Future &future) + void setFuture(const KAsync::Future &future) { - setFutureImpl(*static_cast(&future)); + setFutureImpl(*static_cast(&future)); } - Async::Future future() const + KAsync::Future future() const { - return *static_cast*>(&d->future); + return *static_cast*>(&d->future); } private: -- cgit v1.2.3