diff options
author | Dan Vrátil <dvratil@redhat.com> | 2015-02-20 13:58:03 +0100 |
---|---|---|
committer | Dan Vrátil <dvratil@redhat.com> | 2015-02-20 14:00:49 +0100 |
commit | 8e6f41f851ae058dea63fbc9b9f523ec9fd1a4fb (patch) | |
tree | cbe403f4aaa9498389ab0ddba6af611b99dac98c /common/clientapi.h | |
parent | 1da08ebfe267313015c201fd1106f891af554e14 (diff) | |
download | sink-8e6f41f851ae058dea63fbc9b9f523ec9fd1a4fb.tar.gz sink-8e6f41f851ae058dea63fbc9b9f523ec9fd1a4fb.zip |
Async: allow appending existing Job objects to the Job chain
Now it's possible to do something like
Job<int, int> job = createSomeJob();
auto main = Async::start<int>(....).then(job);
Previously the 'job' would have to be wrapped in a ThenTask-like lambda (which
is what we still do internally), but with this new syntax it's possible to append
another job chain to existing chain easilly. This syntax is available for all
task types.
Diffstat (limited to 'common/clientapi.h')
-rw-r--r-- | common/clientapi.h | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/common/clientapi.h b/common/clientapi.h index c1404da..aa47802 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -421,14 +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 JOBAPI: we should be able to just do, job = job.then(facade->load(..)) | 424 | job = job.then(facade->load(query, addCallback)); |
425 | job = job.then<void>([facade, query, addCallback](Async::Future<void> &future) { | ||
426 | Async::Job<void> j = facade->load(query, addCallback); | ||
427 | j.then<void>([&future, facade](Async::Future<void> &f) { | ||
428 | future.setFinished(); | ||
429 | f.setFinished(); | ||
430 | }).exec(); | ||
431 | }); | ||
432 | } | 425 | } |
433 | job.then<void>([/* eventloop, */resultSet](Async::Future<void> &future) { | 426 | job.then<void>([/* eventloop, */resultSet](Async::Future<void> &future) { |
434 | qDebug() << "Query complete"; | 427 | qDebug() << "Query complete"; |