Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Burger::MutexStatic Class Reference

Class for creating a Mutex for a statically allocated critical section of data. More...

Inheritance diagram for Burger::MutexStatic:
Inheritance graph
[legend]
Collaboration diagram for Burger::MutexStatic:
Collaboration graph
[legend]

Public Member Functions

 MutexStatic () noexcept
 Set the flag that a critical section is initialized.
 
 ~MutexStatic ()
 Clears the flag that a critical section is initialized.
 
void lock (void) noexcept
 Locks a mutex if initialized.
 
uint_t try_lock (void) noexcept
 Tries to lock a mutex if initialized.
 
void unlock (void) noexcept
 Unlocks a mutex if initialized.
 
- Public Member Functions inherited from Burger::Mutex
 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.
 
voidget_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

uint_t m_bValid
 Set to TRUE when constructed.
 
- Protected Attributes inherited from Burger::Mutex
uint32_t m_PlatformMutex [7]
 Platform specific CRITICAL_SECTION or mutex object.
 

Private Member Functions

 MutexStatic (const MutexStatic &)=delete
 
MutexStaticoperator= (const MutexStatic &)=delete
 
 MutexStatic (MutexStatic &&)=delete
 
MutexStaticoperator= (MutexStatic &&)=delete
 

Detailed Description

Class for creating a Mutex for a statically allocated critical section of data.


When an object is created in static memory, the order of startup and shutdown is indeterminate in a cross platform way. To avoid an accidental call to this class before it's constructed or after it's destructed, this class will test a flag to determine if it's out of sequence and if so, the lock() and unlock() functions will perform no action. Since C++'s startup and shutdown sequence is performed on a single thread, this is a safe method to ensure that unknown startup/shutdown sequences won't accidentally thread lock.

See also
Mutex

Constructor & Destructor Documentation

◆ MutexStatic() [1/3]

Burger::MutexStatic::MutexStatic ( const MutexStatic & )
privatedelete

◆ MutexStatic() [2/3]

Burger::MutexStatic::MutexStatic ( MutexStatic && )
privatedelete

◆ MutexStatic() [3/3]

Burger::MutexStatic::MutexStatic ( )
noexcept

Set the flag that a critical section is initialized.


◆ ~MutexStatic()

Burger::MutexStatic::~MutexStatic ( )

Clears the flag that a critical section is initialized.


Member Function Documentation

◆ lock()

Burger::MutexStatic::lock ( void )
inlinenoexcept

Locks a mutex if initialized.


See also
Mutex::lock() and unlock()

◆ operator=() [1/2]

MutexStatic & Burger::MutexStatic::operator= ( const MutexStatic & )
privatedelete

◆ operator=() [2/2]

MutexStatic & Burger::MutexStatic::operator= ( MutexStatic && )
privatedelete

◆ try_lock()

Burger::MutexStatic::try_lock ( void )
inlinenoexcept

Tries to lock a mutex if initialized.


See also
Mutex::try_lock() and lock()

◆ unlock()

Burger::MutexStatic::unlock ( void )
inlinenoexcept

Unlocks a mutex if initialized.


See also
Mutex::unlock() and lock()

Member Data Documentation

◆ m_bValid

uint_t Burger::MutexStatic::m_bValid
protected

Set to TRUE when constructed.