31 #ifndef WRAPPER_DATABASELOCK_HPP_ 32 #define WRAPPER_DATABASELOCK_HPP_ 56 using IsRunningCallback = std::function<bool()>;
89 DatabaseLock(DB& db,
const std::string& lockName, IsRunningCallback isRunningCallback)
90 : ref(db), name(lockName), locked(false) {
91 this->ref.addDatabaseLock(this->name, isRunningCallback);
107 this->ref.removeDatabaseLock(this->name);
109 this->locked =
false;
152 : ref(other.ref), name(other.name), locked(other.locked) {
153 other.locked =
false;
185 this->ref.removeDatabaseLock(this->name);
187 this->locked =
false;
190 this->ref = std::move(other.ref);
191 this->name = std::move(other.name);
192 this->locked = other.locked;
DatabaseLock(DatabaseLock &&other) noexcept
Move constructor.
Definition: DatabaseLock.hpp:151
DatabaseLock & operator=(DatabaseLock &&other) noexcept
Move assignment operator.
Definition: DatabaseLock.hpp:182
Namespace for RAII wrappers and Wrapper::Database.
Definition: Database.hpp:109
bool isActive() const noexcept
Checks the status of the database lock.
Definition: DatabaseLock.hpp:122
virtual ~DatabaseLock()
Destructor unlocking the database.
Definition: DatabaseLock.hpp:105
DatabaseLock(DB &db, const std::string &lockName, IsRunningCallback isRunningCallback)
Constructor locking the database after waiting for another lock if necessary.
Definition: DatabaseLock.hpp:89
Template class for safe in-scope database locks.
Definition: DatabaseLock.hpp:54
DatabaseLock & operator=(DatabaseLock &)=delete
Deleted copy assignment operator.