1 #ifndef _SIGX_LOCK_ACQUIRER_H_
2 #define _SIGX_LOCK_ACQUIRER_H_
29 #include <tr1/type_traits>
30 #include <boost/mpl/eval_if.hpp>
31 #include <boost/mpl/identity.hpp>
87 template<locking_policy I_policy,
typename T_type,
typename T_mutex,
typename T_islockable>
94 typedef typename std::tr1::remove_reference<acquired_type>::type
value_type;
96 typedef typename boost::mpl::eval_if_c<
98 std::tr1::add_const<value_type>,
99 boost::mpl::identity<value_type>
102 typedef typename std::tr1::add_reference<typename std::tr1::remove_volatile<const_or_value_type>::type>::type
reference_type;
112 return l.access_acquiree();
132 template<
typename T_lockfwd_arg1>
134 m_lock(_a_mutex, lockfwd_arg1),
161 template<
typename T_type,
typename T_mutex,
typename T_islockable>
179 template<
typename T_lockfwd_arg1>
180 writelock_acquirer(volatile_reference_type _a_value, mutex_type& _a_mutex, T_lockfwd_arg1 lockfwd_arg1):
185 template<
typename T_type,
typename T_mutex,
typename T_islockable>
203 template<
typename T_lockfwd_arg1>
241 template<locking_policy I_policy,
typename T_type,
typename T_mutex>
247 typename boost::mpl::eval_if<
248 std::tr1::is_const<T_type>,
250 std::tr1::add_const<typename T_type::acquired_type>,
252 boost::mpl::identity<typename T_type::acquired_type>
261 typename boost::mpl::eval_if<
262 std::tr1::is_const<T_type>,
263 std::tr1::add_const<typename T_type::acquired_type>,
264 boost::mpl::identity<typename T_type::acquired_type>
269 typedef T_type lockable_type;
277 parent_type(_a_lockable.access_volatile(), _a_lockable.mutex())
283 template<
typename T_lockfwd_arg1>
285 parent_type(_a_lockable.access_volatile(), _a_lockable.mutex(), lockfwd_arg1)
292 template<
typename T_type,
typename T_mutex>
296 typedef T_type lockable_type;
310 template<
typename T_lockfwd_arg1>
319 template<
typename T_type,
typename T_mutex>
323 typedef T_type lockable_type;
337 template<
typename T_lockfwd_arg1>
351 #endif // end file guard
Metafunction that chooses an appropriate scoped lock for a mutex.
Definition: choose_lock.h:56
T_type acquired_type
Definition: lock_acquirer.h:91
writelock_acquirer(lockable_type &_a_lockable)
Constructs a lock_acquirer from a lockable.
Definition: lock_acquirer.h:303
lock_acquirer(volatile_reference_type _a_value, mutex_type &_a_mutex)
Constructs a lock_acquirer from a volatile type to protect and a lock.
Definition: lock_acquirer.h:123
std::tr1::add_reference< typename std::tr1::add_volatile< value_type >::type >::type volatile_reference_type
Definition: lock_acquirer.h:101
Definition: lock_acquirer.h:186
readlock_acquirer(lockable_type &_a_lockable)
Constructs a lock_acquirer from a lockable.
Definition: lock_acquirer.h:330
lock_acquirer(lockable_type &_a_lockable)
Constructs a lock_acquirer from a lockable.
Definition: lock_acquirer.h:276
readlock_acquirer(volatile_reference_type _a_value, mutex_type &_a_mutex, T_lockfwd_arg1 lockfwd_arg1)
Constructs a lock_acquirer from a volatile type to protect, a lock and an additional argument forward...
Definition: lock_acquirer.h:204
friend reference_type access_acquiree(lock_acquirer &l)
Gives non-volatile access to the locked type.
Definition: lock_acquirer.h:110
choose_lock< mutex_type, I_policy >::type m_lock
lock manager appropriate for the lock type
Definition: lock_acquirer.h:152
Private address operator (operator &) ensures that the address of derived objects can't be taken...
Definition: nonpointeraliasing.h:34
readlock_acquirer(volatile_reference_type _a_value, mutex_type &_a_mutex)
Constructs a lock_acquirer from a volatile type to lock and a lock.
Definition: lock_acquirer.h:196
std::tr1::remove_reference< acquired_type >::type value_type
Definition: lock_acquirer.h:94
Definition: lock_acquirer.h:162
Definition: lockable_fwddecl.h:32
reference_type access_acquiree()
Definition: lock_acquirer.h:143
lock_acquirer(volatile_reference_type _a_value, mutex_type &_a_mutex, T_lockfwd_arg1 lockfwd_arg1)
Constructs a lock_acquirer from a volatile type to protect, a lock and an additional argument forward...
Definition: lock_acquirer.h:133
reference_type m_acquiree
non-const reference to the locked object
Definition: lock_acquirer.h:156
T_mutex mutex_type
Definition: lock_acquirer.h:92
std::tr1::add_reference< typename std::tr1::remove_volatile< const_or_value_type >::type >::type reference_type
Definition: lock_acquirer.h:102
lock_acquirer(lockable_type &_a_lockable, T_lockfwd_arg1 lockfwd_arg1)
Constructs a lock_acquirer from a volatile type to protect, a lock and an additional argument forward...
Definition: lock_acquirer.h:284
writelock_acquirer(lockable_type &_a_lockable, T_lockfwd_arg1 lockfwd_arg1)
Constructs a lock_acquirer from a volatile type to protect, a lock and an additional argument forward...
Definition: lock_acquirer.h:311
readlock_acquirer(lockable_type &_a_lockable, T_lockfwd_arg1 lockfwd_arg1)
Constructs a lock_acquirer from a volatile type to protect, a lock and an additional argument forward...
Definition: lock_acquirer.h:338
Private copy constructor and copy assignment ensure derived classes cannot be copied.
Definition: noncopyable.h:37
writelock_acquirer(volatile_reference_type _a_value, mutex_type &_a_mutex)
Constructs a lock_acquirer from a volatile type to lock and a lock.
Definition: lock_acquirer.h:172
Locks the given mutex and ensures threadsafe write access to the given locked type.
Definition: lock_acquirer.h:88
writelock_acquirer(volatile_reference_type _a_value, mutex_type &_a_mutex, T_lockfwd_arg1 lockfwd_arg1)
Constructs a lock_acquirer from a volatile type to protect, a lock and an additional argument forward...
Definition: lock_acquirer.h:180
boost::mpl::eval_if_c< I_policy==readlock, std::tr1::add_const< value_type >, boost::mpl::identity< value_type > >::type const_or_value_type
Definition: lock_acquirer.h:100