summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-02-02 02:01:45 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-02-02 02:01:45 +0100
commitd10cbf7478cd2edfd44c162c1924109422584e22 (patch)
tree85cf496ef99ee189422ae5ecccac55c489c3c835
parentaa449c82dc3a5505b8a63843b83aed0f5dab8ed1 (diff)
downloadsink-d10cbf7478cd2edfd44c162c1924109422584e22.tar.gz
sink-d10cbf7478cd2edfd44c162c1924109422584e22.zip
Added JOBAPI todo's.
Work for dvratil.
-rw-r--r--common/clientapi.h2
-rw-r--r--common/resourceaccess.cpp7
-rw-r--r--dummyresource/resourcefactory.cpp4
3 files changed, 11 insertions, 2 deletions
diff --git a/common/clientapi.h b/common/clientapi.h
index 6b41116..c1404da 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -421,7 +421,7 @@ public:
421 //We have to bind an instance to the function callback. Since we use a shared pointer this keeps the result provider instance (and thus also the emitter) alive. 421 //We have to bind an instance to the function callback. Since we use a shared pointer this keeps the result provider instance (and thus also the emitter) alive.
422 std::function<void(const typename DomainType::Ptr &)> addCallback = std::bind(&ResultProvider<typename DomainType::Ptr>::add, resultSet, std::placeholders::_1); 422 std::function<void(const typename DomainType::Ptr &)> addCallback = std::bind(&ResultProvider<typename DomainType::Ptr>::add, resultSet, std::placeholders::_1);
423 //We copy the facade pointer to keep it alive 423 //We copy the facade pointer to keep it alive
424 //TODO: we should be able to just do, job = job.then(facade->load(..)) 424 //TODO JOBAPI: we should be able to just do, job = job.then(facade->load(..))
425 job = job.then<void>([facade, query, addCallback](Async::Future<void> &future) { 425 job = job.then<void>([facade, query, addCallback](Async::Future<void> &future) {
426 Async::Job<void> j = facade->load(query, addCallback); 426 Async::Job<void> j = facade->load(query, addCallback);
427 j.then<void>([&future, facade](Async::Future<void> &f) { 427 j.then<void>([&future, facade](Async::Future<void> &f) {
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp
index fc63e7c..c806478 100644
--- a/common/resourceaccess.cpp
+++ b/common/resourceaccess.cpp
@@ -154,6 +154,13 @@ Async::Job<void> ResourceAccess::sendCommand(int commandId)
154 }); 154 });
155} 155}
156 156
157/*
158 * TODO JOBAPI: This is a workaround to be able to return a job below to
159 * may or may not already be finished when the job is started. The job API should provide a mechanism
160 * for this. Essentially we need a way to set a job finished externally (we use the finisher as handle for that).
161 * If the job is then started the continuation should immediately be executed if the job finished already, and otherwise
162 * just wait until the work is done, and then execute the continuation as usual.
163 */
157struct JobFinisher { 164struct JobFinisher {
158 bool finished; 165 bool finished;
159 std::function<void(int error, const QString &errorMessage)> callback; 166 std::function<void(int error, const QString &errorMessage)> callback;
diff --git a/dummyresource/resourcefactory.cpp b/dummyresource/resourcefactory.cpp
index e5019f2..fab3df9 100644
--- a/dummyresource/resourcefactory.cpp
+++ b/dummyresource/resourcefactory.cpp
@@ -168,7 +168,9 @@ private slots:
168 //mPipeline->modifiedEntity 168 //mPipeline->modifiedEntity
169 break; 169 break;
170 case Akonadi2::Commands::CreateEntityCommand: { 170 case Akonadi2::Commands::CreateEntityCommand: {
171 //TODO job lifetime management 171 //TODO JOBAPI: job lifetime management
172 //Right now we're just leaking jobs. In this case we'd like jobs that are heap allocated and delete
173 //themselves once done. In other cases we'd like jobs that only live as long as their handle though.
172 mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()).then<void>([messageQueueCallback, whileCallback](Async::Future<void> &future) { 174 mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()).then<void>([messageQueueCallback, whileCallback](Async::Future<void> &future) {
173 messageQueueCallback(true); 175 messageQueueCallback(true);
174 whileCallback(false); 176 whileCallback(false);