sigx++ 2.0.1
|
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>
Public Member Functions | |
lock_acquirer (lockable_type &_a_lockable) | |
Constructs a lock_acquirer from a lockable. | |
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. |
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.
// 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; }
sigx::lock_acquirer< I_policy, T_type, T_mutex, std::tr1::true_type >::lock_acquirer | ( | lockable_type & | _a_lockable | ) | [inline, explicit] |
Constructs a lock_acquirer from a lockable.
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.