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

Moved a static counter shared among threads to the threadpool

parent e6186f56
......@@ -33,7 +33,7 @@ namespace tapeserver {
namespace daemon {
DiskReadThreadPool::DiskReadThreadPool(int nbThread, unsigned int maxFilesReq,unsigned int maxBytesReq,
castor::log::LogContext lc) : m_lc(lc),m_maxFilesReq(maxFilesReq),m_maxBytesReq(maxBytesReq){
castor::log::LogContext lc) : m_lc(lc),m_maxFilesReq(maxFilesReq),m_maxBytesReq(maxBytesReq),m_nbActiveThread(0){
for(int i=0; i<nbThread; i++) {
DiskReadWorkerThread * thr = new DiskReadWorkerThread(*this);
m_threads.push_back(thr);
......@@ -92,13 +92,12 @@ namespace daemon {
} //end of while(1)
// We now acknowledge to the task injector that read reached the end. There
// will hence be no more requests for more. (last thread turns off the light)
if (0 == --m_nbActiveThread) {
if (0 == --m_parent.m_nbActiveThread) {
m_parent.m_injector->finish();
m_lc.log(LOG_DEBUG, "Signaled to task injector the end of disk read threads");
}
m_lc.log(LOG_DEBUG, "Finishing of DiskReadWorkerThread");
}
tape::threading::AtomicCounter<int> DiskReadThreadPool::DiskReadWorkerThread::m_nbActiveThread(0);
}}}}
......@@ -71,14 +71,13 @@ private:
class DiskReadWorkerThread: private castor::tape::threading::Thread {
public:
DiskReadWorkerThread(DiskReadThreadPool & manager):
m_threadID(m_nbActiveThread++),m_parent(manager),m_lc(m_parent.m_lc) {
m_threadID(m_parent.m_nbActiveThread++),m_parent(manager),m_lc(m_parent.m_lc) {
log::LogContext::ScopedParam param(m_lc, log::Param("threadID", m_threadID));
m_lc.log(LOG_INFO,"DiskWrite Thread created");
}
void startThreads() { start(); }
void waitThreads() { wait(); }
private:
static tape::threading::AtomicCounter<int> m_nbActiveThread;
const int m_threadID;
DiskReadThreadPool & m_parent;
castor::log::LogContext m_lc;
......@@ -90,6 +89,8 @@ private:
MigrationTaskInjector* m_injector;
const unsigned int m_maxFilesReq;
const unsigned int m_maxBytesReq;
tape::threading::AtomicCounter<int> m_nbActiveThread;
};
}}}}
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