Class for creating a Mutex for a critical section of data. More...
Public Member Functions | |
Mutex () noexcept | |
Initialize the data in the class. | |
~Mutex () | |
Shutdown the data in the class. | |
void | lock (void) noexcept |
Locks the mutex. | |
uint_t | try_lock (void) noexcept |
Attempt to lock the mutex. | |
void | unlock (void) noexcept |
Unlocks the mutex. | |
void * | get_platform_mutex (void) noexcept |
Access the platform mutex data. | |
uint32_t | get_threadID (void) const noexcept |
Access the owner thread ID for the SRWLock. | |
uint32_t | get_count (void) const noexcept |
Get the lock count for a SRWLock. | |
void | set_state (uint32_t uCount, uint32_t uThreadID) noexcept |
Set the SRWLock state. | |
uint_t | is_using_SRWlock (void) const noexcept |
Is the Mutex using Window 7 APIs. | |
Protected Attributes | |
uint32_t | m_PlatformMutex [7] |
Platform specific CRITICAL_SECTION or mutex object. | |
Private Member Functions | |
Mutex (const Mutex &)=delete | |
Mutex & | operator= (const Mutex &)=delete |
Mutex (Mutex &&)=delete | |
Mutex & | operator= (Mutex &&)=delete |
Class for creating a Mutex for a critical section of data.
In a multiprocessor system, it's necessary to have multiple threads access the same data at the same time. To prevent data collisions, this class is locked just before the data is used/modified and unlocked after the data access/modification is complete so all CPUs/threads do not have to worry about data collisions.
|
privatedelete |
|
privatedelete |
|
noexcept |
Initialize the data in the class.
Sets up operating system defaults to the data
Burger::Mutex::~Mutex | ( | ) |
Shutdown the data in the class.
Releases the operating system resources allocated by the constructor.
|
inlinenoexcept |
Get the lock count for a SRWLock.
On Windows and Xbox ONE, if the Mutex is managed by an SRWLock, a count is maintained for the number of times a lock was obtained for recursion. Return that count.
|
inlinenoexcept |
Access the platform mutex data.
On platforms that support mutexes, a structure is needed to contain the platform specific mutex. This function returns a pointer to that structure. Use this call with caution because the data returned is platform specific.
|
inlinenoexcept |
Access the owner thread ID for the SRWLock.
On Windows and Xbox ONE, if the Mutex is managed by an SRWLock, a ThreadID of the owner thread is maintained. If it's zero, there is no owner.
|
inlinenoexcept |
|
noexcept |
Locks the mutex.
If the mutex is locked, a lock is obtained and execution continues. If the mutex was already locked, the thread halts until the alternate thread that has this mutex locked releases the lock. There is no timeout.
|
inlinenoexcept |
Set the SRWLock state.
On Windows and Xbox ONE, CondionalVariable may need to override the values of the SRWLock. This call will allow that.
uCount | New recursion level |
uThreadID | New owner ID, can be 0. |
|
noexcept |
|
noexcept |
Unlocks the mutex.
Releases a lock on a mutex and if any other threads are waiting on this lock, they will obtain the lock and the other thread will continue execution. The caller will never block.
|
protected |
Platform specific CRITICAL_SECTION or mutex object.