summaryrefslogtreecommitdiffstats
path: root/common/synchronizer.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-25 08:27:06 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-25 09:23:55 +0100
commit22af1ed535b4afc8db3804e72bc5adb1a1b28d60 (patch)
tree07665f41d5b40d658e95a64bb76020f1fd9d088e /common/synchronizer.h
parent64d7d7bdd1edb2bcc305ca007784d0708cf7ef3c (diff)
downloadsink-22af1ed535b4afc8db3804e72bc5adb1a1b28d60.tar.gz
sink-22af1ed535b4afc8db3804e72bc5adb1a1b28d60.zip
Added the flush command.
Instead of trying to actually flush queues, we send a special command through the same queues as the other commands and can thus guarantee that the respective commands have been processed without blocking anything.
Diffstat (limited to 'common/synchronizer.h')
-rw-r--r--common/synchronizer.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/common/synchronizer.h b/common/synchronizer.h
index 4d5bdd5..99d4877 100644
--- a/common/synchronizer.h
+++ b/common/synchronizer.h
@@ -45,6 +45,7 @@ public:
45 45
46 void setup(const std::function<void(int commandId, const QByteArray &data)> &enqueueCommandCallback, MessageQueue &messageQueue); 46 void setup(const std::function<void(int commandId, const QByteArray &data)> &enqueueCommandCallback, MessageQueue &messageQueue);
47 KAsync::Job<void> synchronize(const Sink::QueryBase &query); 47 KAsync::Job<void> synchronize(const Sink::QueryBase &query);
48 void flush(int commandId, const QByteArray &flushId);
48 49
49 //Read only access to main storage 50 //Read only access to main storage
50 Storage::EntityStore &store(); 51 Storage::EntityStore &store();
@@ -57,6 +58,9 @@ public:
57 58
58 bool allChangesReplayed() Q_DECL_OVERRIDE; 59 bool allChangesReplayed() Q_DECL_OVERRIDE;
59 60
61signals:
62 void notify(Notification);
63
60public slots: 64public slots:
61 virtual void revisionChanged() Q_DECL_OVERRIDE; 65 virtual void revisionChanged() Q_DECL_OVERRIDE;
62 66
@@ -115,23 +119,30 @@ protected:
115 struct SyncRequest { 119 struct SyncRequest {
116 enum RequestType { 120 enum RequestType {
117 Synchronization, 121 Synchronization,
118 ChangeReplay 122 ChangeReplay,
123 Flush
119 }; 124 };
120 125
121 SyncRequest(const Sink::QueryBase &q) 126 SyncRequest(const Sink::QueryBase &q)
122 : flushQueue(false), 127 : requestType(Synchronization),
123 requestType(Synchronization),
124 query(q) 128 query(q)
125 { 129 {
126 } 130 }
127 131
128 SyncRequest(RequestType type) 132 SyncRequest(RequestType type)
129 : flushQueue(false), 133 : requestType(type)
134 {
135 }
136
137 SyncRequest(RequestType type, int flushType_, const QByteArray &flushId_)
138 : flushType(flushType_),
139 flushId(flushId_),
130 requestType(type) 140 requestType(type)
131 { 141 {
132 } 142 }
133 143
134 bool flushQueue; 144 int flushType = 0;
145 QByteArray flushId;
135 RequestType requestType; 146 RequestType requestType;
136 Sink::QueryBase query; 147 Sink::QueryBase query;
137 }; 148 };