39#ifndef BLOCXX_GENERIC_RWLOCK_IMPL_HPP_INCLUDE_GUARD_
40#define BLOCXX_GENERIC_RWLOCK_IMPL_HPP_INCLUDE_GUARD_
41#include "blocxx/BLOCXX_config.h"
63template <
typename IdT,
typename CompareT>
120 typedef std::map<IdT, LockerInfo, CompareT>
IdMap;
129template <
typename IdT,
typename CompareT>
137template <
typename IdT,
typename CompareT>
142template <
typename IdT,
typename CompareT>
149 typename IdMap::iterator info = m_lockerInfo.find(
id);
151 if (info != m_lockerInfo.end())
161 while (!m_canRead || m_numWriters > 0)
173 m_lockerInfo.insert(
typename IdMap::value_type(
id, lockerInfo));
179template <
typename IdT,
typename CompareT>
185 typename IdMap::iterator pInfo = m_lockerInfo.find(
id);
187 if (pInfo == m_lockerInfo.end() || !pInfo->second.isReader())
198 if (m_numReaders == 0)
202 m_waiting_writers.notifyAll();
204 m_lockerInfo.erase(pInfo);
209template <
typename IdT,
typename CompareT>
233 typename IdMap::iterator pInfo = m_lockerInfo.find(
id);
234 if (pInfo != m_lockerInfo.end())
245 if (m_numWriters == 1)
257 while (m_numReaders != 0)
268 if (m_numWriters == 0)
270 m_waiting_readers.notifyAll();
283 while (m_numReaders != 0 || m_numWriters != 0)
291 if (m_numWriters == 0)
293 m_waiting_readers.notifyAll();
302 m_lockerInfo.insert(
typename IdMap::value_type(
id, ti));
310template <
typename IdT,
typename CompareT>
316 typename IdMap::iterator pInfo = m_lockerInfo.find(
id);
318 if (pInfo == m_lockerInfo.end() || !pInfo->second.isWriter())
344 m_waiting_writers.notifyOne();
345 m_lockerInfo.erase(pInfo);
347 m_waiting_readers.notifyAll();
#define BLOCXX_ASSERT(CON)
BLOCXX_ASSERT works similar to the assert() macro, but instead of calling abort(),...
#define BLOCXX_DECLARE_APIEXCEPTION(NAME, LINKAGE_SPEC)
Declare a new exception class named <NAME>Exception that derives from Exception This macro is typical...
#define BLOCXX_THROW(exType, msg)
Throw an exception using FILE and LINE.
The Condition class represents a synchronization device that allows threads to suspend execution and ...
This class is the implementation of the read/write lock.
GenericRWLockImpl(const GenericRWLockImpl &)
void releaseReadLock(const IdT id)
std::map< IdT, LockerInfo, CompareT > IdMap
void acquireReadLock(const IdT id, const Timeout &timeout)
void releaseWriteLock(const IdT id)
GenericRWLockImpl & operator=(const GenericRWLockImpl &)
void acquireWriteLock(const IdT id, const Timeout &timeout)
Condition m_waiting_readers
Condition m_waiting_writers
NonRecursiveMutex m_guard
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
A timeout can be absolute, which means that it will happen at the specified DateTime.
A TimeoutTimer is used by an algorithm to determine when a timeout has expired.
Timeout asAbsoluteTimeout() const
Converts the timer to an absolute timeout.