diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2014-12-21 22:20:31 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2014-12-21 22:20:31 +0100 |
commit | d80ff84c28c0be626c1df4528741cddf5a55f547 (patch) | |
tree | dfa1a3771f52970bfaf7b9e56d8675aeabfc65ef /common/clientapi.h | |
parent | d21aa4e35fb96fa3b07888f710cbc3440af8bdd3 (diff) | |
download | sink-d80ff84c28c0be626c1df4528741cddf5a55f547.tar.gz sink-d80ff84c28c0be626c1df4528741cddf5a55f547.zip |
Write-Read loop from clientside.
It's a huge hack but starts to show results.
Most urgently we need:
* reliable command results
* the 3 buffers instead of the 1
* A way to implement storage as preprocessor (or a place to impelement it after the preprocessors).
Diffstat (limited to 'common/clientapi.h')
-rw-r--r-- | common/clientapi.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/common/clientapi.h b/common/clientapi.h index 6054130..d2757e7 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -278,7 +278,7 @@ public: | |||
278 | virtual void create(const DomainType &domainObject) = 0; | 278 | virtual void create(const DomainType &domainObject) = 0; |
279 | virtual void modify(const DomainType &domainObject) = 0; | 279 | virtual void modify(const DomainType &domainObject) = 0; |
280 | virtual void remove(const DomainType &domainObject) = 0; | 280 | virtual void remove(const DomainType &domainObject) = 0; |
281 | virtual void load(const Query &query, const std::function<void(const typename DomainType::Ptr &)> &resultCallback) = 0; | 281 | virtual void load(const Query &query, const std::function<void(const typename DomainType::Ptr &)> &resultCallback, const std::function<void()> &completeCallback) = 0; |
282 | }; | 282 | }; |
283 | 283 | ||
284 | 284 | ||
@@ -353,7 +353,7 @@ class Store { | |||
353 | public: | 353 | public: |
354 | static QString storageLocation() | 354 | static QString storageLocation() |
355 | { | 355 | { |
356 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2"; | 356 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage"; |
357 | } | 357 | } |
358 | 358 | ||
359 | /** | 359 | /** |
@@ -371,13 +371,24 @@ public: | |||
371 | // Query all resources and aggregate results | 371 | // Query all resources and aggregate results |
372 | // query tells us in which resources we're interested | 372 | // query tells us in which resources we're interested |
373 | // TODO: queries to individual resources could be parallelized | 373 | // TODO: queries to individual resources could be parallelized |
374 | auto eventloop = QSharedPointer<QEventLoop>::create(); | ||
375 | int completeCounter = 0; | ||
374 | for(const QString &resource : query.resources) { | 376 | for(const QString &resource : query.resources) { |
375 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resource); | 377 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resource); |
376 | //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. | 378 | //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. |
377 | std::function<void(const typename DomainType::Ptr &)> addCallback = std::bind(&ResultProvider<typename DomainType::Ptr>::add, resultSet, std::placeholders::_1); | 379 | std::function<void(const typename DomainType::Ptr &)> addCallback = std::bind(&ResultProvider<typename DomainType::Ptr>::add, resultSet, std::placeholders::_1); |
378 | facade->load(query, addCallback); | 380 | //We copy the facade pointer to keep it alive |
381 | facade->load(query, addCallback, [&completeCounter, &query, resultSet, facade, eventloop]() { | ||
382 | //TODO use jobs instead of this counter | ||
383 | completeCounter++; | ||
384 | if (completeCounter == query.resources.size()) { | ||
385 | resultSet->complete(); | ||
386 | eventloop->quit(); | ||
387 | } | ||
388 | }); | ||
379 | } | 389 | } |
380 | resultSet->complete(); | 390 | //The thread contains no eventloop, so execute one here |
391 | eventloop->exec(QEventLoop::ExcludeUserInputEvents); | ||
381 | }); | 392 | }); |
382 | return resultSet->emitter(); | 393 | return resultSet->emitter(); |
383 | } | 394 | } |