MVault 0.0.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
mvlt::RecursiveReadWriteMutex Class Reference

A class for synchronizing threads. More...

#include <ReadWriteMutex.h>

Public Member Functions

void Disable () noexcept
 A function to disable the mutex. It is needed so that you can disable the mutex during inheritance.
 
void ReadLock () noexcept
 A method for locking a section of code for reading.
 
void ReadUnlock () noexcept
 A method for unlocking a section of code for reading.
 
void WriteLock () noexcept
 A method for locking a section of code for writing.
 
void WriteUnlock () noexcept
 A method for unlocking a section of code for writing.
 

Detailed Description

A class for synchronizing threads.

A class for thread management that allows you to lock sections of code for reading or writing. A write lock will ensure that there can only be one thread in the code section at a time. The read lock will ensure that no thread using the write lock gets into the code section until all threads using the read lock are unblocked. At the same time, after the write lock, no new threads with a read lock will enter the code section until all threads using the write lock are unblocked. Recursiveness allows you to call blocking methods in the same thread multiple times without self-locking.

Member Function Documentation

◆ ReadLock()

void mvlt::RecursiveReadWriteMutex::ReadLock ( )
noexcept

A method for locking a section of code for reading.

Using this method, you can lock the code section for reading, which means that all threads using the read lock will have access to data inside the code section but threads using the write lock will wait until all read operations are completed. Note that, in fact, blocking for reading inside writing does not make sense, since the code section is already locked and therefore nothing will happen inside the function in such a situation.

◆ WriteLock()

void mvlt::RecursiveReadWriteMutex::WriteLock ( )
noexcept

A method for locking a section of code for writing.

This method provides exclusive access to a section of code for a single thread. All write operations will be performed sequentially. This method takes precedence over the read lock, which means that after calling this method, no new read operations will be started. Note that if the write lock is called inside the read lock, then this will be equivalent to unlocking for reading and then locking for writing.

◆ WriteUnlock()

void mvlt::RecursiveReadWriteMutex::WriteUnlock ( )
noexcept

A method for unlocking a section of code for writing.

Note that if the write unlock is called inside the read lock, then this will be equivalent to unlocking for writing and then locking for reading.


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