Tkrzw
Public Member Functions | List of all members
tkrzw::SlottedMutex Class Referencefinal

Slotted shared mutex. More...

#include <tkrzw_thread_util.h>

Public Member Functions

 SlottedMutex (int32_t num_slots)
 Constructor. More...
 
 ~SlottedMutex ()
 Destructor. More...
 
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

Slotted shared mutex.

Constructor & Destructor Documentation

◆ SlottedMutex()

tkrzw::SlottedMutex::SlottedMutex ( int32_t  num_slots)
explicit

Constructor.

Parameters
num_slotsThe number of slots.

◆ ~SlottedMutex()

tkrzw::SlottedMutex::~SlottedMutex ( )

Destructor.

Member Function Documentation

◆ GetNumSlots()

int32_t tkrzw::SlottedMutex::GetNumSlots ( ) const

Gets the number of the slots.

@ return the number of the slots.

◆ LockOne()

void tkrzw::SlottedMutex::LockOne ( int32_t  index)

Gets exclusive ownership of a slot.

Parameters
indexThe index of the slot to lock.

◆ UnlockOne()

void tkrzw::SlottedMutex::UnlockOne ( int32_t  index)

Releases exclusive ownership of a slot.

Parameters
indexThe index of the slot to unlock.

◆ LockAll()

void tkrzw::SlottedMutex::LockAll ( )

Gets exclusive ownership of all slots.

◆ UnlockAll()

void tkrzw::SlottedMutex::UnlockAll ( )

Releases exclusive ownership of all slots.

◆ LockOneShared()

void tkrzw::SlottedMutex::LockOneShared ( int32_t  index)

Gets shared ownership of a slot.

Parameters
indexThe index of the slot to lock.

◆ UnlockOneShared()

void tkrzw::SlottedMutex::UnlockOneShared ( int32_t  index)

Releases shared ownership of a slot.

Parameters
indexThe index of the slot to unlock.

◆ LockAllShared()

void tkrzw::SlottedMutex::LockAllShared ( )

Gets shared ownership of all slots.

◆ UnlockAllShared()

void tkrzw::SlottedMutex::UnlockAllShared ( )

Releases exclusive ownership of all slots.