#include <ReadWriteLock.h>

Collaboration diagram for Ipc::ReadWriteLock:

Public Member Functions

 ReadWriteLock ()
bool lockShared ()
 lock for reading or return false More...
bool lockExclusive ()
 lock for modification or return false More...
bool lockHeaders ()
 lock for [readable] metadata update or return false More...
void unlockShared ()
 undo successful sharedLock() More...
void unlockExclusive ()
 undo successful exclusiveLock() More...
void unlockHeaders ()
 undo successful lockHeaders() More...
void switchExclusiveToShared ()
 stop writing, start reading More...
void startAppending ()
 writer keeps its lock but also allows reading More...
void updateStats (ReadWriteLockStats &stats) const
 adds approximate current stats to the supplied ones More...

Public Attributes

std::atomic< uint32_t > readers
 number of reading users More...
std::atomic< bool > writing
 there is a writing user (there can be at most 1) More...
std::atomic< bool > appending
 the writer has promised to only append More...
std::atomic_flag updating
 a reader is updating metadata/headers More...

Private Attributes

std::atomic< uint32_t > readLevel
 number of users reading (or trying to) More...
std::atomic< uint32_t > writeLevel
 number of users writing (or trying to write) More...

Detailed Description

an atomic readers-writer or shared-exclusive lock suitable for maps/tables Also supports reading-while-appending mode when readers and writer are allowed to access the same locked object because the writer promisses to only append new data and all size-related object properties are atomic.

Definition at line 25 of file ReadWriteLock.h.

Constructor & Destructor Documentation

◆ ReadWriteLock()

Member Function Documentation

◆ lockExclusive()

◆ lockHeaders()

bool Ipc::ReadWriteLock::lockHeaders ( )

Definition at line 49 of file ReadWriteLock.cc.

References lockShared(), unlockShared(), and updating.

Referenced by Ipc::StoreMap::openForUpdating(), and ReadWriteLock().

◆ lockShared()

bool Ipc::ReadWriteLock::lockShared ( )

◆ startAppending()

void Ipc::ReadWriteLock::startAppending ( )

Definition at line 95 of file ReadWriteLock.cc.

References appending, assert, and writing.

Referenced by ReadWriteLock(), and Ipc::StoreMap::startAppending().

◆ switchExclusiveToShared()

void Ipc::ReadWriteLock::switchExclusiveToShared ( )

◆ unlockExclusive()

◆ unlockHeaders()

void Ipc::ReadWriteLock::unlockHeaders ( )

◆ unlockShared()

◆ updateStats()

Member Data Documentation

◆ appending

std::atomic<bool> Ipc::ReadWriteLock::appending

◆ readers

◆ readLevel

std::atomic<uint32_t> Ipc::ReadWriteLock::readLevel

Definition at line 51 of file ReadWriteLock.h.

Referenced by lockExclusive(), lockShared(), switchExclusiveToShared(), and unlockShared().

◆ updating

std::atomic_flag Ipc::ReadWriteLock::updating

◆ writeLevel

std::atomic<uint32_t> Ipc::ReadWriteLock::writeLevel

Definition at line 52 of file ReadWriteLock.h.

Referenced by lockExclusive(), lockShared(), and unlockExclusive().

◆ writing

std::atomic<bool> Ipc::ReadWriteLock::writing

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






Web Site Translations