summaryrefslogtreecommitdiffstats
path: root/common/synchronizer.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-22 18:25:31 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-22 18:25:31 +0100
commite513ee41adb6061aa72de8bfe49d117f47c1545b (patch)
treed91fd8abb5d2f47ec24dff497bcf18e218f01641 /common/synchronizer.h
parentec16f3b92d6017462f4bba8354b53d1707850430 (diff)
downloadsink-e513ee41adb6061aa72de8bfe49d117f47c1545b.tar.gz
sink-e513ee41adb6061aa72de8bfe49d117f47c1545b.zip
Support dependencies between sync requests.
If one sync task depends on the previous sync task we want to flush in between, so we can query for the results of the previous sync request locally. If we detect such a dependency we temporarily halt all processing of synchronization requests until the flush completes, so we can continue processing.
Diffstat (limited to 'common/synchronizer.h')
-rw-r--r--common/synchronizer.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/common/synchronizer.h b/common/synchronizer.h
index a0a432c..be90293 100644
--- a/common/synchronizer.h
+++ b/common/synchronizer.h
@@ -57,6 +57,7 @@ public:
57 Sink::Storage::DataStore::Transaction &syncTransaction(); 57 Sink::Storage::DataStore::Transaction &syncTransaction();
58 58
59 bool allChangesReplayed() Q_DECL_OVERRIDE; 59 bool allChangesReplayed() Q_DECL_OVERRIDE;
60 void flushComplete(const QByteArray &flushId);
60 61
61signals: 62signals:
62 void notify(Notification); 63 void notify(Notification);
@@ -123,9 +124,15 @@ protected:
123 Flush 124 Flush
124 }; 125 };
125 126
126 SyncRequest(const Sink::QueryBase &q, const QByteArray &requestId_ = QByteArray()) 127 enum RequestOptions {
128 NoOptions,
129 RequestFlush
130 };
131
132 SyncRequest(const Sink::QueryBase &q, const QByteArray &requestId_ = QByteArray(), RequestOptions o = NoOptions)
127 : requestId(requestId_), 133 : requestId(requestId_),
128 requestType(Synchronization), 134 requestType(Synchronization),
135 options(o),
129 query(q) 136 query(q)
130 { 137 {
131 } 138 }
@@ -145,6 +152,7 @@ protected:
145 int flushType = 0; 152 int flushType = 0;
146 QByteArray requestId; 153 QByteArray requestId;
147 RequestType requestType; 154 RequestType requestType;
155 RequestOptions options = NoOptions;
148 Sink::QueryBase query; 156 Sink::QueryBase query;
149 }; 157 };
150 158
@@ -181,6 +189,7 @@ private:
181 QList<SyncRequest> mSyncRequestQueue; 189 QList<SyncRequest> mSyncRequestQueue;
182 MessageQueue *mMessageQueue; 190 MessageQueue *mMessageQueue;
183 bool mSyncInProgress; 191 bool mSyncInProgress;
192 QMultiHash<QByteArray, SyncRequest> mPendingSyncRequests;
184}; 193};
185 194
186} 195}