winss
|
A global mutex where the key is derived from a file path and service name. More...
#include <path_mutex.hpp>
Public Member Functions | |
PathMutex (fs::path path, std::string name) | |
Create a path mutex with a path and a name. More... | |
PathMutex (const PathMutex &)=delete | |
No copy. More... | |
PathMutex (PathMutex &&)=delete | |
No move. More... | |
virtual bool | Lock () |
Attempts to get the mutex. More... | |
virtual bool | CanLock () const |
Checks if the lock will fail or not. More... | |
virtual bool | HasLock () const |
Checks if this instance owns the lock. More... | |
virtual const std::string & | GetName () const |
Gets the name of the service. More... | |
PathMutex & | operator= (const PathMutex &)=delete |
No copy. More... | |
PathMutex & | operator= (PathMutex &&)=delete |
No move. More... | |
virtual | ~PathMutex () |
Default destructor. More... | |
Protected Member Functions | |
PathMutex () | |
Hide the default constructor. More... | |
Protected Attributes | |
std::string | mutex_name |
The service name. More... | |
HANDLE | lock = nullptr |
A handle to the Windows mutex. More... | |
A global mutex where the key is derived from a file path and service name.
|
inlineprotected |
Hide the default constructor.
References CanLock(), GetName(), HasLock(), Lock(), operator=(), and ~PathMutex().
winss::PathMutex::PathMutex | ( | fs::path | path, |
std::string | name | ||
) |
Create a path mutex with a path and a name.
path | The path under lock. |
name | The name of the service. |
References winss::SHA256::CalculateDigest(), FILESYSTEM, and mutex_name.
|
delete |
No copy.
|
delete |
No move.
|
virtual |
|
virtual |
Checks if the lock will fail or not.
References HasLock(), lock, mutex_name, and WINDOWS.
Referenced by PathMutex().
|
virtual |
Gets the name of the service.
References mutex_name.
Referenced by PathMutex().
|
virtual |
Checks if this instance owns the lock.
References lock.
Referenced by CanLock(), Lock(), PathMutex(), and ~PathMutex().
|
virtual |
Attempts to get the mutex.
References HasLock(), lock, mutex_name, and WINDOWS.
Referenced by PathMutex().
No copy.
Referenced by PathMutex().
|
protected |
A handle to the Windows mutex.
Referenced by CanLock(), HasLock(), Lock(), and ~PathMutex().
|
protected |
The service name.
Referenced by CanLock(), GetName(), Lock(), and PathMutex().