diff --git a/src/Init.cpp b/src/Init.cpp index 5c2fff0c..aaf3e937 100644 --- a/src/Init.cpp +++ b/src/Init.cpp @@ -168,7 +168,7 @@ void STDCALL SetResources( memory.Resize(static_cast(noOfThreads), DDS_TT_SMALL, THREADMEM_SMALL_DEF_MB, THREADMEM_SMALL_MAX_MB); - threadMgr.Reset(noOfThreads); + threadMgr.Reset(static_cast(noOfThreads)); InitDebugFiles(); diff --git a/src/ThreadMgr.cpp b/src/ThreadMgr.cpp index d922ad23..6055a4e9 100644 --- a/src/ThreadMgr.cpp +++ b/src/ThreadMgr.cpp @@ -34,12 +34,12 @@ ThreadMgr::~ThreadMgr() } -void ThreadMgr::Reset(const int nThreads) +void ThreadMgr::Reset(const unsigned int nThreads) { if (nThreads > numRealThreads) { realThreads.resize(nThreads); - for (int t = numRealThreads; t < nThreads; t++) + for (unsigned int t = numRealThreads; t < nThreads; t++) realThreads[t] = false; numRealThreads = nThreads; } @@ -47,20 +47,20 @@ void ThreadMgr::Reset(const int nThreads) if (nThreads > numMachineThreads) { machineThreads.resize(nThreads); - for (int t = numMachineThreads; t < nThreads; t++) + for (unsigned int t = numMachineThreads; t < nThreads; t++) machineThreads[t] = -1; numMachineThreads = nThreads; } } -int ThreadMgr::Occupy(const int machineId) +int ThreadMgr::Occupy(const unsigned int machineId) { if (machineId >= numMachineThreads) { numMachineThreads = machineId + 1; machineThreads.resize(numMachineThreads); - for (int t = machineId; t < numMachineThreads; t++) + for (unsigned int t = machineId; t < numMachineThreads; t++) machineThreads[t] = -1; } @@ -75,13 +75,13 @@ int ThreadMgr::Occupy(const int machineId) do { mtx.lock(); - for (int t = 0; t < numRealThreads; t++) + for (unsigned int t = 0; t < numRealThreads; t++) { if (realThreads[t] == false) { realThreads[t] = true; - machineThreads[machineId] = t; - res = t; + machineThreads[machineId] = static_cast(t); + res = static_cast(t); break; } } @@ -100,7 +100,7 @@ int ThreadMgr::Occupy(const int machineId) } -bool ThreadMgr::Release(const int machineId) +bool ThreadMgr::Release(const unsigned int machineId) { const int r = machineThreads[machineId]; if (r == -1) @@ -109,14 +109,14 @@ bool ThreadMgr::Release(const int machineId) return false; } - if (! realThreads[r]) + if (! realThreads[static_cast(r)]) { // Error: Refers to a real thread that is not in use. return false; } mtx.lock(); - realThreads[r] = false; + realThreads[static_cast(r)] = false; machineThreads[machineId] = -1; mtx.unlock(); return true; @@ -133,7 +133,7 @@ void ThreadMgr::Print( fo << tag << ": Real threads occupied (out of " << numRealThreads << "):\n"; - for (int t = 0; t < numRealThreads; t++) + for (unsigned int t = 0; t < numRealThreads; t++) { if (realThreads[t]) fo << t << endl; @@ -141,7 +141,7 @@ void ThreadMgr::Print( fo << endl; fo << "Machine threads overview:\n"; - for (int t = 0; t < numMachineThreads; t++) + for (unsigned int t = 0; t < numMachineThreads; t++) { if (machineThreads[t] != -1) { diff --git a/src/ThreadMgr.h b/src/ThreadMgr.h index f9c595ff..f36f280f 100644 --- a/src/ThreadMgr.h +++ b/src/ThreadMgr.h @@ -21,8 +21,8 @@ class ThreadMgr vector realThreads; vector machineThreads; - int numRealThreads; - int numMachineThreads; + unsigned int numRealThreads; + unsigned int numMachineThreads; public: @@ -30,11 +30,11 @@ class ThreadMgr ~ThreadMgr(); - void Reset(const int nThreads); + void Reset(const unsigned int nThreads); - int Occupy(const int MachineThrId); + int Occupy(const unsigned int MachineThrId); - bool Release(const int MachineThrId); + bool Release(const unsigned int MachineThrId); void Print( const string& fname,