Scheduler: ability to return the number of local workers

metadata
Wenzel Jakob 2011-01-12 02:07:34 +01:00
parent eb7a6ff5ea
commit 07bc3a23fe
2 changed files with 14 additions and 0 deletions

View File

@ -400,6 +400,9 @@ public:
/// Get the number of workers
size_t getWorkerCount() const;
/// Get the number of local workers
size_t getLocalWorkerCount() const;
/// Retrieve one of the workers by index
Worker *getWorker(int index);

View File

@ -99,6 +99,17 @@ size_t Scheduler::getWorkerCount() const {
return count;
}
size_t Scheduler::getLocalWorkerCount() const {
size_t count = 0;
m_mutex->lock();
for (size_t i=0; i<m_workers.size(); ++i) {
if (m_workers[i]->getClass() == LocalWorker::m_theClass)
count++;
}
m_mutex->unlock();
return count;
}
bool Scheduler::isBusy() const {
bool result;
m_mutex->lock(); // make valgrind/helgrind happy