Moved Locker class out of LockedStorage to accomodate GCC compiler.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@791 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
6eabeea489
commit
97e1fd6b59
1 changed files with 32 additions and 32 deletions
|
@ -238,43 +238,43 @@ namespace Loki
|
||||||
/// LockedStorage which calls other functions to lock the object.
|
/// LockedStorage which calls other functions to lock the object.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class Locker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Locker( const T * p ) : pointee_( const_cast< T * >( p ) )
|
||||||
|
{
|
||||||
|
if ( pointee_ != 0 )
|
||||||
|
pointee_->Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
~Locker( void )
|
||||||
|
{
|
||||||
|
if ( pointee_ != 0 )
|
||||||
|
pointee_->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
operator T * ()
|
||||||
|
{
|
||||||
|
return pointee_;
|
||||||
|
}
|
||||||
|
|
||||||
|
T * operator->()
|
||||||
|
{
|
||||||
|
return pointee_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Locker( void );
|
||||||
|
Locker & operator = ( const Locker & );
|
||||||
|
T * pointee_;
|
||||||
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class LockedStorage
|
class LockedStorage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template <class T>
|
|
||||||
class Locker
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Locker( const T * p ) : pointee_( const_cast< T * >( p ) )
|
|
||||||
{
|
|
||||||
if ( pointee_ != 0 )
|
|
||||||
pointee_->Lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Locker( void )
|
|
||||||
{
|
|
||||||
if ( pointee_ != 0 )
|
|
||||||
pointee_->Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
operator T * ()
|
|
||||||
{
|
|
||||||
return pointee_;
|
|
||||||
}
|
|
||||||
|
|
||||||
T * operator->()
|
|
||||||
{
|
|
||||||
return pointee_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Locker( void );
|
|
||||||
Locker & operator = ( const Locker & );
|
|
||||||
T * pointee_;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef T* StoredType; /// the type of the pointee_ object
|
typedef T* StoredType; /// the type of the pointee_ object
|
||||||
typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
|
typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
|
||||||
typedef Locker< T > PointerType; /// type returned by operator->
|
typedef Locker< T > PointerType; /// type returned by operator->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue