#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

Ipc::ReadWriteLock::ReadWriteLock ( )
inline

Definition at line 28 of file ReadWriteLock.h.

Member Function Documentation

bool Ipc::ReadWriteLock::lockHeaders ( )

Definition at line 49 of file ReadWriteLock.cc.

Referenced by Ipc::StoreMap::openForUpdating().

bool Ipc::ReadWriteLock::lockShared ( )
void Ipc::ReadWriteLock::startAppending ( )

Definition at line 95 of file ReadWriteLock.cc.

References assert.

Referenced by Ipc::StoreMap::startAppending().

void Ipc::ReadWriteLock::switchExclusiveToShared ( )
void Ipc::ReadWriteLock::unlockHeaders ( )

Member Data Documentation

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

Definition at line 47 of file ReadWriteLock.h.

Referenced by Ipc::StoreMap::abortWriting(), and lockShared().

std::atomic<uint32_t> Ipc::ReadWriteLock::readers
mutable
std::atomic<uint32_t> Ipc::ReadWriteLock::readLevel
mutableprivate

Definition at line 51 of file ReadWriteLock.h.

Referenced by lockShared().

std::atomic_flag Ipc::ReadWriteLock::updating
std::atomic<uint32_t> Ipc::ReadWriteLock::writeLevel
private

Definition at line 52 of file ReadWriteLock.h.

Referenced by lockShared().

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

Definition at line 46 of file ReadWriteLock.h.

Referenced by Ipc::MemMapSlot::writing(), and Ipc::StoreMapAnchor::writing().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors