Tkrzw
Public Member Functions | List of all members
tkrzw::SlottedMutex< SHAREDMUTEX > Class Template Referencefinal

Slotted shared mutex. More...

#include <tkrzw_thread_util.h>

Public Member Functions

 SlottedMutex (int32_t num_slots)
 Constructor. More...
 
 ~SlottedMutex ()
 Destructor. More...
 
 SlottedMutex (const SlottedMutex &rhs)=delete
 Copy and assignment are disabled. More...
 
SlottedMutexoperator= (const SlottedMutex &rhs)=delete
 
int32_t GetNumSlots () const
 Gets the number of the slots. More...
 
void LockOne (int32_t index)
 Gets exclusive ownership of a slot. More...
 
void UnlockOne (int32_t index)
 Releases exclusive ownership of a slot. More...
 
void LockAll ()
 Gets exclusive ownership of all slots. More...
 
void UnlockAll ()
 Releases exclusive ownership of all slots. More...
 
void LockOneShared (int32_t index)
 Gets shared ownership of a slot. More...
 
void UnlockOneShared (int32_t index)
 Releases shared ownership of a slot. More...
 
void LockAllShared ()
 Gets shared ownership of all slots. More...
 
void UnlockAllShared ()
 Releases exclusive ownership of all slots. More...
 

Detailed Description

template<typename SHAREDMUTEX = std::shared_mutex>
class tkrzw::SlottedMutex< SHAREDMUTEX >

Slotted shared mutex.

Constructor & Destructor Documentation

◆ SlottedMutex() [1/2]

template<typename SHAREDMUTEX >
tkrzw::SlottedMutex< SHAREDMUTEX >::SlottedMutex ( int32_t  num_slots)
explicit

Constructor.

Parameters
num_slotsThe number of slots.

◆ ~SlottedMutex()

template<typename SHAREDMUTEX >
tkrzw::SlottedMutex< SHAREDMUTEX >::~SlottedMutex

Destructor.

◆ SlottedMutex() [2/2]

template<typename SHAREDMUTEX = std::shared_mutex>
tkrzw::SlottedMutex< SHAREDMUTEX >::SlottedMutex ( const SlottedMutex< SHAREDMUTEX > &  rhs)
explicitdelete

Copy and assignment are disabled.

Member Function Documentation

◆ GetNumSlots()

template<typename SHAREDMUTEX >
int32_t tkrzw::SlottedMutex< SHAREDMUTEX >::GetNumSlots

Gets the number of the slots.

@ return the number of the slots.

◆ LockOne()

template<typename SHAREDMUTEX >
void tkrzw::SlottedMutex< SHAREDMUTEX >::LockOne ( int32_t  index)

Gets exclusive ownership of a slot.

Parameters
indexThe index of the slot to lock.

◆ UnlockOne()

template<typename SHAREDMUTEX >
void tkrzw::SlottedMutex< SHAREDMUTEX >::UnlockOne ( int32_t  index)

Releases exclusive ownership of a slot.

Parameters
indexThe index of the slot to unlock.

◆ LockAll()

template<typename SHAREDMUTEX >
void tkrzw::SlottedMutex< SHAREDMUTEX >::LockAll

Gets exclusive ownership of all slots.

◆ UnlockAll()

template<typename SHAREDMUTEX >
void tkrzw::SlottedMutex< SHAREDMUTEX >::UnlockAll

Releases exclusive ownership of all slots.

◆ LockOneShared()

template<typename SHAREDMUTEX >
void tkrzw::SlottedMutex< SHAREDMUTEX >::LockOneShared ( int32_t  index)

Gets shared ownership of a slot.

Parameters
indexThe index of the slot to lock.

◆ UnlockOneShared()

template<typename SHAREDMUTEX >
void tkrzw::SlottedMutex< SHAREDMUTEX >::UnlockOneShared ( int32_t  index)

Releases shared ownership of a slot.

Parameters
indexThe index of the slot to unlock.

◆ LockAllShared()

template<typename SHAREDMUTEX >
void tkrzw::SlottedMutex< SHAREDMUTEX >::LockAllShared

Gets shared ownership of all slots.

◆ UnlockAllShared()

template<typename SHAREDMUTEX >
void tkrzw::SlottedMutex< SHAREDMUTEX >::UnlockAllShared

Releases exclusive ownership of all slots.