add ctor with std::pair argument
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@705 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
e8468b8291
commit
c249b0f93b
2 changed files with 25 additions and 0 deletions
|
@ -47,6 +47,18 @@ namespace Loki
|
|||
mutex.Lock();
|
||||
}
|
||||
|
||||
typedef typename std::pair<volatile ConstOrNotType *, LockingPolicy *> Pair;
|
||||
|
||||
/** Constructor locks mutex associated with an object.
|
||||
@param lockpair a std::pair of pointers to the object and the mutex
|
||||
*/
|
||||
LockingPtr( Pair lockpair )
|
||||
: pObject_( const_cast< SharedObject * >( lockpair.first ) ),
|
||||
pMutex_( lockpair.second )
|
||||
{
|
||||
lockpair.second->Lock();
|
||||
}
|
||||
|
||||
/// Destructor unlocks the mutex.
|
||||
~LockingPtr()
|
||||
{
|
||||
|
@ -91,6 +103,9 @@ namespace Loki
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.12 2006/10/11 08:51:40 syntheticpp
|
||||
// add ctor with std::pair argument
|
||||
//
|
||||
// Revision 1.11 2006/03/08 18:22:42 syntheticpp
|
||||
// doxygen fixes
|
||||
//
|
||||
|
|
|
@ -124,6 +124,16 @@ int main ()
|
|||
Thread::JoinThreads(threads);
|
||||
Thread::DeleteThreads(threads);
|
||||
|
||||
|
||||
// test pair ctor
|
||||
volatile A a;
|
||||
Loki::Mutex m;
|
||||
UserLockingPtr::Pair pair(&a,&m);
|
||||
UserLockingPtr l( pair );
|
||||
|
||||
ConstUserLockingPtr::Pair cpair(&a,&m);
|
||||
ConstUserLockingPtr cl( cpair );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue