sigx++  2.0.1
Public Member Functions
sigx::lock_acquirer< I_policy, T_type, T_mutex, std::tr1::true_type > Class Template Reference

Specialization for a lockable_base derived object; locks the given lockable object (e.g. a mutex_lockable) and ensures threadsafe write access to the locked type. More...

#include <lock_acquirer.h>

Inheritance diagram for sigx::lock_acquirer< I_policy, T_type, T_mutex, std::tr1::true_type >:
sigx::lock_acquirer< I_policy, T_type, T_mutex, T_islockable > sigx::noncopyable sigx::nonpointeraliasing

Public Member Functions

 lock_acquirer (lockable_type &_a_lockable)
 Constructs a lock_acquirer from a lockable. More...
 
template<typename T_lockfwd_arg1 >
 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 forwarded to the lock constructor. More...
 
- Public Member Functions inherited from sigx::lock_acquirer< I_policy, T_type, T_mutex, T_islockable >
 lock_acquirer (volatile_reference_type _a_value, mutex_type &_a_mutex)
 Constructs a lock_acquirer from a volatile type to protect and a lock. More...
 
template<typename T_lockfwd_arg1 >
 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 forwarded to the lock constructor. More...
 

Additional Inherited Members

- Protected Types inherited from sigx::lock_acquirer< I_policy, T_type, T_mutex, T_islockable >
typedef T_type acquired_type
 
typedef T_mutex mutex_type
 
typedef
std::tr1::remove_reference
< acquired_type >::type 
value_type
 
typedef boost::mpl::eval_if_c
< I_policy==readlock,
std::tr1::add_const
< value_type >
, boost::mpl::identity
< value_type > >::type 
const_or_value_type
 
typedef
std::tr1::add_reference
< typename
std::tr1::add_volatile
< value_type >::type >::type 
volatile_reference_type
 
typedef
std::tr1::add_reference
< typename
std::tr1::remove_volatile
< const_or_value_type >::type >
::type 
reference_type
 
- Protected Member Functions inherited from sigx::lock_acquirer< I_policy, T_type, T_mutex, T_islockable >
reference_type access_acquiree () throw ()
 
- Protected Attributes inherited from sigx::lock_acquirer< I_policy, T_type, T_mutex, T_islockable >
choose_lock< mutex_type,
I_policy >::type 
m_lock
 lock manager appropriate for the lock type More...
 
reference_type m_acquiree
 non-const reference to the locked object More...
 

Detailed Description

template<locking_policy I_policy, typename T_type, typename T_mutex>
class sigx::lock_acquirer< I_policy, T_type, T_mutex, std::tr1::true_type >

Specialization for a lockable_base derived object; locks the given lockable object (e.g. a mutex_lockable) and ensures threadsafe write access to the locked type.

Collects acquisition of a mutex lock and a volatile_cast from the volatile object contained in the lockable. A lock_acquirer object is initialized with a lockable object. During its lifetime, a lock_acquirer keeps the lock acquired. Also, lock_acquirer offers write access to the volatile-stripped object. The access is offered with a related access_acquiree() function. The volatile_cast is performed by access_acquiree(). The cast is semantically valid because lock_acquirer keeps the lock acquired for its lifetime.

The following template arguments are used:

The lock_acquirer chooses the appropriate lock manager for the lock automatically by applying the choose_lock.

Note
The locked type can only be accessed with access_acquiree()
// somewhere
mutex_lockable<int> lockable_int;
// a scope somewhere else
{
lock_acquirer<writelock, mutex_lockable<int> > l(lockable_int);
int& i = access_acquiree(l);
i = 42;
}

Constructor & Destructor Documentation

template<locking_policy I_policy, typename T_type , typename T_mutex >
sigx::lock_acquirer< I_policy, T_type, T_mutex, std::tr1::true_type >::lock_acquirer ( lockable_type &  _a_lockable)
inlineexplicit

Constructs a lock_acquirer from a lockable.

Note
Acquires the lock immediately, unlocks when it goes out of scope
template<locking_policy I_policy, typename T_type , typename T_mutex >
template<typename T_lockfwd_arg1 >
sigx::lock_acquirer< I_policy, T_type, T_mutex, std::tr1::true_type >::lock_acquirer ( lockable_type &  _a_lockable,
T_lockfwd_arg1  lockfwd_arg1 
)
inline

Constructs a lock_acquirer from a volatile type to protect, a lock and an additional argument forwarded to the lock constructor.

Note
Acquires the lock immediately, unlocks when it goes out of scope

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