Resolve a #define clash with the template argument LOCK.

This commit is contained in:
curt 2001-06-06 23:12:03 +00:00
parent a6ac06c47a
commit 29dfc5bd3c
2 changed files with 11 additions and 11 deletions

View File

@ -6,16 +6,16 @@
* An SGGuard object locks its synchronization object during creation and
* automatically unlocks it when it goes out of scope.
*/
template<class LOCK>
template<class SGLOCK>
class SGGuard
{
public:
/**
* Create an SGGuard object and lock the passed lockable object.
* @param LOCK A lockable object.
* @param SGLOCK A lockable object.
*/
inline SGGuard( LOCK& l ) : lock(l) { lock.lock(); }
inline SGGuard( SGLOCK& l ) : lock(l) { lock.lock(); }
/**
* Destroy this object and unlock the locakable object.
@ -27,12 +27,12 @@ private:
/**
* A lockable object.
*/
LOCK& lock;
SGLOCK& lock;
private:
// Disable copying.
SGGuard(const LOCK&);
LOCK& operator= (const LOCK&);
SGGuard(const SGLOCK&);
SGLOCK& operator= (const SGLOCK&);
};
#endif // SGGUARD_HXX_INCLUDED

View File

@ -64,7 +64,7 @@ protected:
/**
* A simple thread safe queue. All access functions are guarded with a mutex.
*/
template<class T, class LOCK=SGMutex>
template<class T, class SGLOCK=SGMutex>
class SGLockedQueue : public SGQueue<T>
{
public:
@ -85,7 +85,7 @@ public:
* @return bool True if queue is empty, otherwisr false.
*/
virtual bool empty() {
SGGuard<LOCK> g(mutex);
SGGuard<SGLOCK> g(mutex);
return fifo.empty();
}
@ -95,7 +95,7 @@ public:
* @param T object to add.
*/
virtual void push( const T& item ) {
SGGuard<LOCK> g(mutex);
SGGuard<SGLOCK> g(mutex);
fifo.push( item );
}
@ -105,7 +105,7 @@ public:
* @return T next available object.
*/
virtual T pop() {
SGGuard<LOCK> g(mutex);
SGGuard<SGLOCK> g(mutex);
//if (fifo.empty()) throw NoSuchElementException();
assert( ! fifo.empty() );
// if (fifo.empty())
@ -122,7 +122,7 @@ private:
/**
* Mutex to serialise access.
*/
LOCK mutex;
SGLOCK mutex;
private:
// Prevent copying.