* 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.
/**
* 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
/**
* 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:
* @return bool True if queue is empty, otherwisr false.
*/
virtual bool empty() {
- SGGuard<LOCK> g(mutex);
+ SGGuard<SGLOCK> g(mutex);
return fifo.empty();
}
* @param T object to add.
*/
virtual void push( const T& item ) {
- SGGuard<LOCK> g(mutex);
+ SGGuard<SGLOCK> g(mutex);
fifo.push( item );
}
* @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())
/**
* Mutex to serialise access.
*/
- LOCK mutex;
+ SGLOCK mutex;
private:
// Prevent copying.