aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/update/Walk.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-27 16:36:11 +0100
committerMax Kellermann <max@duempel.org>2014-02-27 16:58:35 +0100
commit681e012fb542ee1bb2ea5312dc673987a7a8ee29 (patch)
tree2887e01d906c89f99516d67c555a2318473cc169 /src/db/update/Walk.hxx
parent3be36643a1bded02171d8ddaac7d7aecfdc1915a (diff)
downloadmpd-681e012fb542ee1bb2ea5312dc673987a7a8ee29.tar.gz
mpd-681e012fb542ee1bb2ea5312dc673987a7a8ee29.tar.xz
mpd-681e012fb542ee1bb2ea5312dc673987a7a8ee29.zip
db/update: cancel the update on shutdown
Diffstat (limited to 'src/db/update/Walk.hxx')
-rw-r--r--src/db/update/Walk.hxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/db/update/Walk.hxx b/src/db/update/Walk.hxx
index bf3eb8ae4..353f6f3ed 100644
--- a/src/db/update/Walk.hxx
+++ b/src/db/update/Walk.hxx
@@ -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;
@@ -57,6 +64,22 @@ public:
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.
*/
bool Walk(Directory &root, const char *path, bool discard);