db/update: cancel the update on shutdown

This commit is contained in:
Max Kellermann
2014-02-27 16:36:11 +01:00
parent 3be36643a1
commit 681e012fb5
7 changed files with 59 additions and 1 deletions

View File

@@ -48,6 +48,13 @@ class UpdateWalk final {
bool walk_discard;
bool modified;
/**
* Set to true by the main thread when the update thread shall
* cancel as quickly as possible. Access to this flag is
* unprotected.
*/
volatile bool cancel;
Storage &storage;
DatabaseEditor editor;
@@ -56,6 +63,22 @@ public:
UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
Storage &_storage);
/**
* Cancel the current update and quit the Walk() method as
* soon as possible.
*/
void Cancel() {
cancel = true;
}
/**
* Call from the main thread before starting the update
* thread.
*/
void Prepare() {
cancel = false;
}
/**
* Returns true if the database was modified.
*/