libfoedus-core
FOEDUS Core Library
|
A mutex that can be placed in shared memory and used from multiple processes. More...
A mutex that can be placed in shared memory and used from multiple processes.
C++11's mutex doesn't work for multi-process. We need to directly manipulate pthread_mutexattr_setpshared, hence this class. This object is also shared-memory friendly, meaning it has no heap-allocated member. It can be reset to a usable state via memset(zero), too.
Example usage:
Definition at line 47 of file shared_mutex.hpp.
#include <shared_mutex.hpp>
Public Member Functions | |
SharedMutex () | |
~SharedMutex () | |
SharedMutex (const SharedMutex &)=delete | |
SharedMutex & | operator= (const SharedMutex &)=delete |
void | initialize (bool recursive=false) |
void | uninitialize () |
bool | is_initialized () const |
bool | is_recursive () const |
void | lock () |
Unconditionally lock. More... | |
bool | timedlock (uint64_t timeout_nanosec) |
Try lock up to the given timeout. More... | |
bool | trylock () |
Instantaneously try the lock. More... | |
void | unlock () |
Unlock it. More... | |
pthread_mutex_t * | get_raw_mutex () |
|
inline |
Definition at line 49 of file shared_mutex.hpp.
References initialize().
|
inline |
Definition at line 50 of file shared_mutex.hpp.
References uninitialize().
|
delete |
|
inline |
Definition at line 80 of file shared_mutex.hpp.
Referenced by foedus::soc::SharedCond::timedwait(), and foedus::soc::SharedCond::wait().
void foedus::soc::SharedMutex::initialize | ( | bool | recursive = false | ) |
Definition at line 29 of file shared_mutex.cpp.
References ASSERT_ND, and uninitialize().
Referenced by foedus::log::MetaLogControlBlock::initialize(), foedus::proc::ProcManagerControlBlock::initialize(), foedus::savepoint::SavepointManagerControlBlock::initialize(), foedus::memory::PagePoolControlBlock::initialize(), foedus::storage::StorageManagerControlBlock::initialize(), foedus::log::LogManagerControlBlock::initialize(), foedus::soc::SharedCond::initialize(), foedus::thread::ThreadControlBlock::initialize(), foedus::storage::StorageControlBlock::initialize(), foedus::log::LoggerControlBlock::initialize(), foedus::storage::PartitionerMetadata::initialize(), and SharedMutex().
|
inline |
Definition at line 58 of file shared_mutex.hpp.
Referenced by foedus::storage::array::ArrayPartitioner::ArrayPartitioner(), foedus::storage::hash::HashPartitioner::design_partition(), foedus::storage::array::ArrayPartitioner::design_partition(), foedus::storage::hash::HashPartitioner::HashPartitioner(), foedus::snapshot::SnapshotManagerPimpl::initialize_once(), and foedus::snapshot::SnapshotManagerPimpl::uninitialize_once().
|
inline |
Definition at line 59 of file shared_mutex.hpp.
void foedus::soc::SharedMutex::lock | ( | ) |
Unconditionally lock.
Definition at line 63 of file shared_mutex.cpp.
References ASSERT_ND.
Referenced by foedus::soc::SharedMutexScope::lock().
|
delete |
bool foedus::soc::SharedMutex::timedlock | ( | uint64_t | timeout_nanosec | ) |
Try lock up to the given timeout.
[in] | timeout_nanosec | timeout in nanoseconds |
Definition at line 69 of file shared_mutex.cpp.
References ASSERT_ND, CXX11_NULLPTR, and trylock().
bool foedus::soc::SharedMutex::trylock | ( | ) |
Instantaneously try the lock.
Definition at line 87 of file shared_mutex.cpp.
References ASSERT_ND.
Referenced by timedlock().
void foedus::soc::SharedMutex::uninitialize | ( | ) |
Definition at line 49 of file shared_mutex.cpp.
References ASSERT_ND.
Referenced by initialize(), foedus::proc::ProcManagerControlBlock::uninitialize(), foedus::log::MetaLogControlBlock::uninitialize(), foedus::memory::PagePoolControlBlock::uninitialize(), foedus::storage::StorageManagerControlBlock::uninitialize(), foedus::soc::SharedCond::uninitialize(), foedus::savepoint::SavepointManagerControlBlock::uninitialize(), foedus::log::LogManagerControlBlock::uninitialize(), foedus::storage::StorageControlBlock::uninitialize(), foedus::thread::ThreadControlBlock::uninitialize(), foedus::log::LoggerControlBlock::uninitialize(), foedus::storage::PartitionerMetadata::uninitialize(), and ~SharedMutex().
void foedus::soc::SharedMutex::unlock | ( | ) |
Unlock it.
Definition at line 93 of file shared_mutex.cpp.
References ASSERT_ND.
Referenced by foedus::soc::SharedMutexScope::unlock().