25 #ifndef INCLUDED_SharedMemoryObjectWithMutex_h_GUID_8A1DE87D_04F9_4689_6CAC_6D8579B0464D 26 #define INCLUDED_SharedMemoryObjectWithMutex_h_GUID_8A1DE87D_04F9_4689_6CAC_6D8579B0464D 32 #include <boost/interprocess/interprocess_fwd.hpp> 33 #include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp> 34 #include <boost/interprocess/sync/sharable_lock.hpp> 35 #include <boost/interprocess/sync/scoped_lock.hpp> 44 namespace bip = boost::interprocess;
48 typedef bip::scoped_lock<mutex_type> exclusive_lock_type;
49 typedef bip::sharable_lock<mutex_type> sharable_lock_type;
53 sharable_lock_type getSharableLock() {
54 return sharable_lock_type(getMutex());
56 exclusive_lock_type getExclusiveLock() {
57 return exclusive_lock_type(getMutex());
59 mutex_type &getMutex() {
return m_mutex; }
63 if (!lock || (lock.mutex() != &m_mutex)) {
64 throw std::logic_error(
"Lock passed must be " 65 "exclusively locked and for the " 71 template <
typename LockType>
73 if (!lock || (lock.mutex() != &m_mutex)) {
74 throw std::logic_error(
75 "Lock passed must be " 76 "at least sharably locked and for the " 89 #endif // INCLUDED_SharedMemoryObjectWithMutex_h_GUID_8A1DE87D_04F9_4689_6CAC_6D8579B0464D void verifyWriterLock(exclusive_lock_type &lock) const
Checks to make sure we have a writer (exclusive) lock.
Definition: SharedMemoryObjectWithMutex.h:62
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
void verifyReaderLock(LockType &lock) const
Checks to make sure we at least have a reader (sharable) lock.
Definition: SharedMemoryObjectWithMutex.h:72
bip::interprocess_upgradable_mutex mutex_type
Using it as a shared mutex - but that wasn't added until boost 1.52.
Definition: SharedMemoryObjectWithMutex.h:47
Definition: SharedMemoryObjectWithMutex.h:51