winss
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
winss::PathMutex Class Reference

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...
 
PathMutexoperator= (const PathMutex &)=delete
 No copy. More...
 
PathMutexoperator= (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...
 

Detailed Description

A global mutex where the key is derived from a file path and service name.

Constructor & Destructor Documentation

winss::PathMutex::PathMutex ( )
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.

Parameters
pathThe path under lock.
nameThe name of the service.

References winss::SHA256::CalculateDigest(), FILESYSTEM, and mutex_name.

winss::PathMutex::PathMutex ( const PathMutex )
delete

No copy.

winss::PathMutex::PathMutex ( PathMutex &&  )
delete

No move.

winss::PathMutex::~PathMutex ( )
virtual

Default destructor.

References HasLock(), lock, and WINDOWS.

Referenced by PathMutex().

Member Function Documentation

bool winss::PathMutex::CanLock ( ) const
virtual

Checks if the lock will fail or not.

Returns
True if getting the mutex will be successful otherwise false.

References HasLock(), lock, mutex_name, and WINDOWS.

Referenced by PathMutex().

const std::string & winss::PathMutex::GetName ( ) const
virtual

Gets the name of the service.

Returns
The name of the service.

References mutex_name.

Referenced by PathMutex().

bool winss::PathMutex::HasLock ( ) const
virtual

Checks if this instance owns the lock.

Returns
True if this instance owns the lock otherwise false.

References lock.

Referenced by CanLock(), Lock(), PathMutex(), and ~PathMutex().

bool winss::PathMutex::Lock ( )
virtual

Attempts to get the mutex.

Returns
True if getting the mutex was successful otherwise false.

References HasLock(), lock, mutex_name, and WINDOWS.

Referenced by PathMutex().

PathMutex& winss::PathMutex::operator= ( const PathMutex )
delete

No copy.

Referenced by PathMutex().

PathMutex& winss::PathMutex::operator= ( PathMutex &&  )
delete

No move.

Member Data Documentation

HANDLE winss::PathMutex::lock = nullptr
protected

A handle to the Windows mutex.

Referenced by CanLock(), HasLock(), Lock(), and ~PathMutex().

std::string winss::PathMutex::mutex_name
protected

The service name.

Referenced by CanLock(), GetName(), Lock(), and PathMutex().


The documentation for this class was generated from the following files: