Add front() methods SGQueue, SGLockedQueue, and SGBlockingQueue so that the

can be used more interchangably with a regular STL queue.
This commit is contained in:
curt
2004-02-28 18:51:20 +00:00
parent aa67c738a1
commit 79d72b6292

View File

@@ -47,6 +47,13 @@ public:
*/
virtual void push( const T& item ) = 0;
/**
* View the item from the head of the queue.
*
* @return T next available object.
*/
virtual T front() = 0;
/**
* Get an item from the head of the queue.
*
@@ -99,6 +106,18 @@ public:
fifo.push( item );
}
/**
* View the item from the head of the queue.
*
* @return T next available object.
*/
virtual T front() {
SGGuard<SGLOCK> g(mutex);
assert( ! fifo.empty() );
T item = fifo.front();
return item;
}
/**
* Get an item from the head of the queue.
*
@@ -167,6 +186,22 @@ public:
not_empty.signal();
}
/**
* View the item from the head of the queue.
* Calling thread is not suspended
*
* @return T next available object.
*/
virtual T front() {
SGGuard<SGMutex> g(mutex);
assert(fifo.empty() != true);
//if (fifo.empty()) throw ??
T item = fifo.front();
return item;
}
/**
* Get an item from the head of the queue.
* If no items are available then the calling thread is suspended