summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-12-15 23:33:07 +0100
committerMax Kellermann <max@duempel.org>2015-12-16 00:07:51 +0100
commit7dd3b72a8ca193ac82a602a17e161bc573e5f44c (patch)
tree7a25c6750224a6fc0574876b9eca803af1a7fa63 /src/db
parentaeccccb33df8a4323bf65a4e3e44359293be90c1 (diff)
db/DatabaseLock: add ScopeDatabaseLock::unlock()
Diffstat (limited to 'src/db')
-rw-r--r--src/db/DatabaseLock.hxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/db/DatabaseLock.hxx b/src/db/DatabaseLock.hxx
index 786c97899..253eb73fb 100644
--- a/src/db/DatabaseLock.hxx
+++ b/src/db/DatabaseLock.hxx
@@ -84,13 +84,26 @@ db_unlock(void)
}
class ScopeDatabaseLock {
+ bool locked = true;
+
public:
ScopeDatabaseLock() {
db_lock();
}
~ScopeDatabaseLock() {
+ if (locked)
+ db_unlock();
+ }
+
+ /**
+ * Unlock the mutex now, making the destructor a no-op.
+ */
+ void unlock() {
+ assert(locked);
+
db_unlock();
+ locked = false;
}
};