Since there's no external lock, it was impossible to check the queue was non-empty before a pop, without a race condition. To avoid this, tolerate an empty queue and return a default constructed value.
*/
virtual T pop() {
SGGuard<SGMutex> g(mutex);
- //if (fifo.empty()) throw NoSuchElementException();
- assert( ! this->fifo.empty() );
+ if (this->fifo.empty()) return T(); // assumes T is default constructable
+
// if (fifo.empty())
// {
// mutex.unlock();