MADNESS  0.10.1
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
madness::MutexReaderWriter Class Reference

#include <worldmutex.h>

Inheritance diagram for madness::MutexReaderWriter:
Inheritance graph
[legend]
Collaboration diagram for madness::MutexReaderWriter:
Collaboration graph
[legend]

Public Member Functions

 MutexReaderWriter ()
 
virtual ~MutexReaderWriter ()
 
void convert_read_lock_to_write_lock () const
 Converts read to write lock without releasing the read lock. More...
 
void convert_write_lock_to_read_lock () const
 Always succeeds immediately. More...
 
void lock (int lockmode) const
 
void read_lock () const
 
void read_unlock () const
 
bool try_convert_read_lock_to_write_lock () const
 
bool try_lock (int lockmode) const
 
bool try_read_lock () const
 
bool try_write_lock () const
 
void unlock (int lockmode) const
 
void write_lock () const
 
void write_unlock () const
 

Static Public Attributes

static const int NOLOCK =0
 
static const int READLOCK =1
 
static const int WRITELOCK =2
 

Private Attributes

int nreader
 
bool writeflag
 

Additional Inherited Members

- Private Member Functions inherited from madness::Spinlock
 Spinlock (int junk=0)
 Make and initialize a spinlock ... initial state is unlocked. More...
 
virtual ~Spinlock ()
 
void lock () const
 Acquire the spinlock waiting if necessary. More...
 
bool try_lock () const
 Try to acquire the spinlock ... return true on success, false on failure. More...
 
void unlock () const
 Free a spinlock owned by this thread. More...
 
- Private Member Functions inherited from NO_DEFAULTS
 NO_DEFAULTS ()
 
 NO_DEFAULTS (const NO_DEFAULTS &)=delete
 
 NO_DEFAULTS (NO_DEFAULTS &&)=delete
 
NO_DEFAULTSoperator= (const NO_DEFAULTS &)=delete
 
NO_DEFAULTSoperator= (NO_DEFAULTS &&)=delete
 

Constructor & Destructor Documentation

◆ MutexReaderWriter()

madness::MutexReaderWriter::MutexReaderWriter ( )
inline

◆ ~MutexReaderWriter()

virtual madness::MutexReaderWriter::~MutexReaderWriter ( )
inlinevirtual

Member Function Documentation

◆ convert_read_lock_to_write_lock()

void madness::MutexReaderWriter::convert_read_lock_to_write_lock ( ) const
inline

Converts read to write lock without releasing the read lock.

Note that deadlock is guaranteed if two+ threads wait to convert at the same time.

References madness::cpu_relax(), and try_convert_read_lock_to_write_lock().

Referenced by madness::Hash_private::HashAccessor< hashT, lockmode >::convert_read_lock_to_write_lock().

◆ convert_write_lock_to_read_lock()

void madness::MutexReaderWriter::convert_write_lock_to_read_lock ( ) const
inline

Always succeeds immediately.

References nreader, and writeflag.

◆ lock()

void madness::MutexReaderWriter::lock ( int  lockmode) const
inline

◆ read_lock()

void madness::MutexReaderWriter::read_lock ( ) const
inline

◆ read_unlock()

void madness::MutexReaderWriter::read_unlock ( ) const
inline

References nreader.

Referenced by unlock().

◆ try_convert_read_lock_to_write_lock()

bool madness::MutexReaderWriter::try_convert_read_lock_to_write_lock ( ) const
inline

References nreader, and writeflag.

Referenced by convert_read_lock_to_write_lock().

◆ try_lock()

bool madness::MutexReaderWriter::try_lock ( int  lockmode) const
inline

◆ try_read_lock()

bool madness::MutexReaderWriter::try_read_lock ( ) const
inline

References nreader, and writeflag.

Referenced by read_lock(), and try_lock().

◆ try_write_lock()

bool madness::MutexReaderWriter::try_write_lock ( ) const
inline

References nreader, and writeflag.

Referenced by try_lock(), and write_lock().

◆ unlock()

void madness::MutexReaderWriter::unlock ( int  lockmode) const
inline

◆ write_lock()

void madness::MutexReaderWriter::write_lock ( ) const
inline

◆ write_unlock()

void madness::MutexReaderWriter::write_unlock ( ) const
inline

References writeflag.

Referenced by unlock().

Member Data Documentation

◆ NOLOCK

const int madness::MutexReaderWriter::NOLOCK =0
static

◆ nreader

int madness::MutexReaderWriter::nreader
mutableprivate

◆ READLOCK

const int madness::MutexReaderWriter::READLOCK =1
static

◆ writeflag

bool madness::MutexReaderWriter::writeflag
mutableprivate

◆ WRITELOCK

const int madness::MutexReaderWriter::WRITELOCK =2
static

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