|
crawlserv++
[under development]
Application for crawling and analyzing textual content of websites.
|
Template class for safe in-scope database locks. More...
#include <DatabaseLock.hpp>
Construction and Destruction | |
| DatabaseLock (DB &db, const std::string &lockName, IsRunningCallback isRunningCallback) | |
| Constructor locking the database after waiting for another lock if necessary. More... | |
| virtual | ~DatabaseLock () |
| Destructor unlocking the database. More... | |
Getter | |
| bool | isActive () const noexcept |
| Checks the status of the database lock. More... | |
Copy and Move | |
| DatabaseLock (DatabaseLock &)=delete | |
| Deleted copy constructor. More... | |
| DatabaseLock & | operator= (DatabaseLock &)=delete |
| Deleted copy assignment operator. More... | |
| DatabaseLock (DatabaseLock &&other) noexcept | |
| Move constructor. More... | |
| DatabaseLock & | operator= (DatabaseLock &&other) noexcept |
| Move assignment operator. More... | |
Template class for safe in-scope database locks.
Locks the database for specific actions on construction, unlocks it on destruction.
| DB | Database connection to be used for the lock. Must implement the member functions addDatabaseLock() and removeDatabaseLock(), i.e. inherit from Main::Database. |
|
inline |
Constructor locking the database after waiting for another lock if necessary.
If no other lock with the same name is active, the database will be locked by calling an implementation of Main::Database::addDatabaseLock.
Otherwise, the constructor will wait for the other lock to be released.
| db | The database connection to use. |
| lockName | The name of the lock. If there is another DatabaseLock active with the same name, the constructor will wait until it is destructed. |
| isRunningCallback | A function that returns whether both the current thread and program are still running. |
Referenced by crawlservpp::Wrapper::DatabaseLock< DB >::isActive().
|
inlinevirtual |
Destructor unlocking the database.
If the constructor was successful in locking the database, the lock will be removed by calling an implementation of Main::Database::removeDatabaseLock.
|
delete |
Deleted copy constructor.
|
inlinenoexcept |
Move constructor.
Moves the database lock from the specified location into this instance of the class.
| other | The database lock to move from. |
|
inlinenoexcept |
Checks the status of the database lock.
References crawlservpp::Wrapper::DatabaseLock< DB >::DatabaseLock(), and crawlservpp::Wrapper::DatabaseLock< DB >::operator=().
|
delete |
Deleted copy assignment operator.
Referenced by crawlservpp::Wrapper::DatabaseLock< DB >::isActive().
|
inlinenoexcept |
Move assignment operator.
Moves the database lock from the specified location into this instance of the class.
If the current instance already holds a database lock, it will be released before moving in the other lock.
| other | The database lock to move from. |
*this).