Commit a15e87b1 authored by David COME's avatar David COME
Browse files

Got rid of BlockingQueue::tryPop and changed the memory managers destructor to...

Got rid of BlockingQueue::tryPop and changed the memory managers destructor to use instead popGetSize
parent 713f2ed6
......@@ -133,14 +133,12 @@ public:
// castor::tape::threading::Thread::wait();
// we expect to be called after all users are finished. Just "free"
// the memory blocks we still have.
try {
while(true) {
delete m_freeBlocks.tryPop();
}
}
catch (castor::tape::threading::noMore) {
//done
}
castor::tape::threading::BlockingQueue<MemBlock*>::valueRemainingPair ret;
do{
ret=m_freeBlocks.popGetSize();
delete ret.value;
}while(ret.remaining>0);
m_lc.log(LOG_INFO,"MigrationMemoryManager destruction : all memory blocks have been deleted");
}
private:
......
......@@ -92,14 +92,13 @@ public:
// castor::tape::threading::Thread::wait();
// we expect to be called after all users are finished. Just "free"
// the memory blocks we still have.
try {
while(true) {
delete m_freeBlocks.tryPop();
}
}
catch (castor::tape::threading::noMore) {
//done
}
castor::tape::threading::BlockingQueue<MemBlock*>::valueRemainingPair ret;
do{
ret=m_freeBlocks.popGetSize();
delete ret.value;
}while(ret.remaining>0);
m_lc.log(LOG_INFO,"RecallMemoryManager destruction : all memory blocks have been deleted");
}
......
......@@ -15,17 +15,7 @@
namespace castor {
namespace tape {
namespace threading {
/**
* Exception class used to signal there are no more elements
*/
class noMore : public castor::tape::Exception
{
public:
noMore():Exception("")
{}
};
/***
* This simple class provides a thread-safe blocking queue
*
......@@ -56,22 +46,19 @@ public:
m_sem.acquire();
return popCriticalSection();
}
/**
* Atomically pop the element of the top of the pile AND return it with the
* number of remaining elements in the queue
* @return a struct holding the popped element (into ret.value) and the number of elements
* remaining (into ret.remaining)
*
*/
valueRemainingPair popGetSize () {
m_sem.acquire();
valueRemainingPair ret;
ret.value = popCriticalSection(&ret.remaining);
return ret;
}
/**
* Return the next value of the queue and remove it
* if there are no elements, throws a no noMoreElements exception
*/
C tryPop() {
if (!m_sem.tryAcquire()) throw noMore();
return popCriticalSection();
}
///return the number of elements currently in the queue
size_t size() const {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment