libfoedus-core
FOEDUS Core Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
foedus::soc::SharedMutexScope Class Referencefinal

Auto-lock scope object for SharedMutex. More...

Detailed Description

Auto-lock scope object for SharedMutex.

SharedMutex itself has auto-release feature, but only when it is on stack. In many cases SharedMutex is placed in shared memory, so its destructor is never called. Instead, this object provides the auto-release semantics.

Definition at line 100 of file shared_mutex.hpp.

#include <shared_mutex.hpp>

Public Member Functions

 SharedMutexScope (SharedMutex *mutex, bool lock_initially=true)
 
 ~SharedMutexScope ()
 
 SharedMutexScope (const SharedMutexScope &)=delete
 
SharedMutexScopeoperator= (const SharedMutexScope &)=delete
 
bool is_locked_by_me () const
 
SharedMutexget_mutex () const
 
void lock ()
 
void unlock ()
 

Constructor & Destructor Documentation

foedus::soc::SharedMutexScope::SharedMutexScope ( SharedMutex mutex,
bool  lock_initially = true 
)
inline

Definition at line 102 of file shared_mutex.hpp.

References lock().

103  : mutex_(mutex), locked_by_me_(false) {
104  if (lock_initially) {
105  lock();
106  }
107  }

Here is the call graph for this function:

foedus::soc::SharedMutexScope::~SharedMutexScope ( )
inline

Definition at line 108 of file shared_mutex.hpp.

References unlock().

Here is the call graph for this function:

foedus::soc::SharedMutexScope::SharedMutexScope ( const SharedMutexScope )
delete

Member Function Documentation

SharedMutex* foedus::soc::SharedMutexScope::get_mutex ( ) const
inline

Definition at line 115 of file shared_mutex.hpp.

Referenced by foedus::storage::PartitionerMetadata::allocate_data().

115 { return mutex_; }

Here is the caller graph for this function:

bool foedus::soc::SharedMutexScope::is_locked_by_me ( ) const
inline

Definition at line 114 of file shared_mutex.hpp.

Referenced by foedus::storage::PartitionerMetadata::allocate_data().

114 { return locked_by_me_; }

Here is the caller graph for this function:

void foedus::soc::SharedMutexScope::lock ( )

Definition at line 99 of file shared_mutex.cpp.

References foedus::soc::SharedMutex::lock().

Referenced by SharedMutexScope().

99  {
100  if (locked_by_me_) {
101  return;
102  }
103 
104  mutex_->lock();
105  locked_by_me_ = true;
106 }
void lock()
Unconditionally lock.

Here is the call graph for this function:

Here is the caller graph for this function:

SharedMutexScope& foedus::soc::SharedMutexScope::operator= ( const SharedMutexScope )
delete
void foedus::soc::SharedMutexScope::unlock ( )

Definition at line 108 of file shared_mutex.cpp.

References foedus::soc::SharedMutex::unlock().

Referenced by foedus::soc::SharedCond::broadcast(), foedus::soc::SharedCond::signal(), and ~SharedMutexScope().

108  {
109  if (!locked_by_me_) {
110  return;
111  }
112 
113  mutex_->unlock();
114  locked_by_me_ = false;
115 }
void unlock()
Unlock it.

Here is the call graph for this function:

Here is the caller graph for this function:


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