From d10cbf7478cd2edfd44c162c1924109422584e22 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 2 Feb 2015 02:01:45 +0100 Subject: Added JOBAPI todo's. Work for dvratil. --- common/clientapi.h | 2 +- common/resourceaccess.cpp | 7 +++++++ dummyresource/resourcefactory.cpp | 4 +++- 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: //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. std::function addCallback = std::bind(&ResultProvider::add, resultSet, std::placeholders::_1); //We copy the facade pointer to keep it alive - //TODO: we should be able to just do, job = job.then(facade->load(..)) + //TODO JOBAPI: we should be able to just do, job = job.then(facade->load(..)) job = job.then([facade, query, addCallback](Async::Future &future) { Async::Job j = facade->load(query, addCallback); j.then([&future, facade](Async::Future &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 ResourceAccess::sendCommand(int commandId) }); } +/* + * TODO JOBAPI: This is a workaround to be able to return a job below to + * may or may not already be finished when the job is started. The job API should provide a mechanism + * for this. Essentially we need a way to set a job finished externally (we use the finisher as handle for that). + * If the job is then started the continuation should immediately be executed if the job finished already, and otherwise + * just wait until the work is done, and then execute the continuation as usual. + */ struct JobFinisher { bool finished; std::function 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: //mPipeline->modifiedEntity break; case Akonadi2::Commands::CreateEntityCommand: { - //TODO job lifetime management + //TODO JOBAPI: job lifetime management + //Right now we're just leaking jobs. In this case we'd like jobs that are heap allocated and delete + //themselves once done. In other cases we'd like jobs that only live as long as their handle though. mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()).then([messageQueueCallback, whileCallback](Async::Future &future) { messageQueueCallback(true); whileCallback(false); -- cgit v1.2.3