diff options
author | Max Kellermann <max@duempel.org> | 2015-12-15 23:33:07 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-12-16 00:07:51 +0100 |
commit | 7dd3b72a8ca193ac82a602a17e161bc573e5f44c (patch) | |
tree | 7a25c6750224a6fc0574876b9eca803af1a7fa63 /src/db | |
parent | aeccccb33df8a4323bf65a4e3e44359293be90c1 (diff) |
db/DatabaseLock: add ScopeDatabaseLock::unlock()
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/DatabaseLock.hxx | 13 |
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; } }; |