added Loki-Namespace-Qualification to definition of ClassLevelLockable's static member.

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@128 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
humesikkins 2003-03-25 23:52:04 +00:00
parent 39e2a0557e
commit 0ec9a1db40

View file

@ -8,11 +8,11 @@
// affects only default template arguments // affects only default template arguments
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Last update: Feb 20, 2003 // Last update: Mar 26, 2003
// note: In this VC 6 port all template policies become non-templates with // note: In this VC 6 port all template policies become non-templates with
// either member-template functions or a nested template struct named In // either member-template functions or a nested template struct named In
// Changed wrong ctor/dtor names in ObjectLevelLockable. // Changed wrong ctor/dtor names in ObjectLevelLockable.
// Thanks to Adi Shavit for pointing that out // Thanks to Adi Shavit for pointing that out
#ifndef DEFAULT_THREADING #ifndef DEFAULT_THREADING
@ -37,26 +37,26 @@ namespace Loki
Lock() {} Lock() {}
explicit Lock(const SingleThreaded&) {} explicit Lock(const SingleThreaded&) {}
}; };
typedef Host VolatileType; typedef Host VolatileType;
typedef int IntType; typedef int IntType;
static IntType AtomicAdd(volatile IntType& lval, IntType val) static IntType AtomicAdd(volatile IntType& lval, IntType val)
{ return lval += val; } { return lval += val; }
static IntType AtomicSubtract(volatile IntType& lval, IntType val) static IntType AtomicSubtract(volatile IntType& lval, IntType val)
{ return lval -= val; } { return lval -= val; }
static IntType AtomicMultiply(volatile IntType& lval, IntType val) static IntType AtomicMultiply(volatile IntType& lval, IntType val)
{ return lval *= val; } { return lval *= val; }
static IntType AtomicDivide(volatile IntType& lval, IntType val) static IntType AtomicDivide(volatile IntType& lval, IntType val)
{ return lval /= val; } { return lval /= val; }
static IntType AtomicIncrement(volatile IntType& lval) static IntType AtomicIncrement(volatile IntType& lval)
{ return ++lval; } { return ++lval; }
static IntType AtomicDecrement(volatile IntType& lval) static IntType AtomicDecrement(volatile IntType& lval)
{ return --lval; } { return --lval; }
@ -69,12 +69,12 @@ namespace Loki
*/ */
static void AtomicAssign(volatile IntType & lval, IntType val) static void AtomicAssign(volatile IntType & lval, IntType val)
{ lval = val; } { lval = val; }
static void AtomicAssign(IntType & lval, volatile IntType & val) static void AtomicAssign(IntType & lval, volatile IntType & val)
{ lval = val; } { lval = val; }
}; };
}; };
#ifdef _WINDOWS_ #ifdef _WINDOWS_
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -83,7 +83,7 @@ namespace Loki
// Implements a object-level locking scheme // Implements a object-level locking scheme
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
struct ObjectLevelLockable struct ObjectLevelLockable
{ {
template <class Host> template <class Host>
@ -105,11 +105,11 @@ namespace Loki
class Lock; class Lock;
friend class Lock; friend class Lock;
class Lock class Lock
{ {
ObjectLevelLockable::In<Host>& host_; ObjectLevelLockable::In<Host>& host_;
Lock(const Lock&); Lock(const Lock&);
Lock& operator=(const Lock&); Lock& operator=(const Lock&);
//Lock(); // buggy design //Lock(); // buggy design
@ -127,22 +127,22 @@ namespace Loki
typedef volatile Host VolatileType; typedef volatile Host VolatileType;
typedef LONG IntType; typedef LONG IntType;
static IntType AtomicIncrement(volatile IntType& lval) static IntType AtomicIncrement(volatile IntType& lval)
{ return InterlockedIncrement(&const_cast<IntType&>(lval)); } { return InterlockedIncrement(&const_cast<IntType&>(lval)); }
static IntType AtomicDecrement(volatile IntType& lval) static IntType AtomicDecrement(volatile IntType& lval)
{ return InterlockedDecrement(&const_cast<IntType&>(lval)); } { return InterlockedDecrement(&const_cast<IntType&>(lval)); }
static void AtomicAssign(volatile IntType& lval, IntType val) static void AtomicAssign(volatile IntType& lval, IntType val)
{ InterlockedExchange(&const_cast<IntType&>(lval), val); } { InterlockedExchange(&const_cast<IntType&>(lval), val); }
static void AtomicAssign(IntType& lval, volatile IntType& val) static void AtomicAssign(IntType& lval, volatile IntType& val)
{ InterlockedExchange(&lval, val); } { InterlockedExchange(&lval, val); }
}; };
}; };
struct ClassLevelLockable struct ClassLevelLockable
{ {
template <class Host> template <class Host>
@ -152,8 +152,8 @@ namespace Loki
struct Initializer; struct Initializer;
friend struct Initializer; friend struct Initializer;
struct Initializer struct Initializer
{ {
CRITICAL_SECTION mtx_; CRITICAL_SECTION mtx_;
Initializer() Initializer()
@ -165,13 +165,13 @@ namespace Loki
::DeleteCriticalSection(&mtx_); ::DeleteCriticalSection(&mtx_);
} }
}; };
static Initializer initializer_; static Initializer initializer_;
public: public:
class Lock; class Lock;
friend class Lock; friend class Lock;
class Lock class Lock
{ {
Lock(const Lock&); Lock(const Lock&);
@ -193,27 +193,27 @@ namespace Loki
typedef volatile Host VolatileType; typedef volatile Host VolatileType;
typedef LONG IntType; typedef LONG IntType;
static IntType AtomicIncrement(volatile IntType& lval) static IntType AtomicIncrement(volatile IntType& lval)
{ return InterlockedIncrement(&const_cast<IntType&>(lval)); } { return InterlockedIncrement(&const_cast<IntType&>(lval)); }
static IntType AtomicDecrement(volatile IntType& lval) static IntType AtomicDecrement(volatile IntType& lval)
{ return InterlockedDecrement(&const_cast<IntType&>(lval)); } { return InterlockedDecrement(&const_cast<IntType&>(lval)); }
static void AtomicAssign(volatile IntType& lval, IntType val) static void AtomicAssign(volatile IntType& lval, IntType val)
{ InterlockedExchange(&const_cast<IntType&>(lval), val); } { InterlockedExchange(&const_cast<IntType&>(lval), val); }
static void AtomicAssign(IntType& lval, volatile IntType& val) static void AtomicAssign(IntType& lval, volatile IntType& val)
{ InterlockedExchange(&lval, val); } { InterlockedExchange(&lval, val); }
}; };
}; };
template <class Host> template <class Host>
typename ClassLevelLockable::template In<Host>::Initializer typename Loki::ClassLevelLockable::template In<Host>::Initializer
ClassLevelLockable::template In<Host>::initializer_; Loki::ClassLevelLockable::template In<Host>::initializer_;
#endif #endif
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -221,6 +221,8 @@ namespace Loki
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!! // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
// Oct 06, 2002: ported by Benjamin Kaufmann to MSVC 6.0 // Oct 06, 2002: ported by Benjamin Kaufmann to MSVC 6.0
// Feb 20, 2003: corrected constructor parameter in ObjectLevelLockable::Lock // Feb 20, 2003: corrected constructor parameter in ObjectLevelLockable::Lock
// Mar 26, 2003: added Loki-Namespace-Qualification to definition of
// ClassLevelLockable's static member.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#endif #endif