Skip to content

Commit bde69c1

Browse files
committed
fixed thread bug and added worker poolstats via store
1 parent 9043590 commit bde69c1

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/DataModelBase/Utilities.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ void *Utilities::Thread(void *arg){
4242
}
4343
catch (std::exception& p) {
4444
std::clog<<"Thread function Failed:"<<p.what() <<std::endl;
45-
running = false;
45+
args->running = false;
4646
}
4747
catch(...){
4848
std::clog<<"Thread function Failed"<<std::endl;
49-
running = false;
49+
args->running = false;
5050
}
51+
}
5152
else usleep(100);
5253

5354
}

src/DataModelBase/WorkerPoolManager.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,29 @@ std::string WorkerPoolManager::GetStats(){
265265

266266
}
267267

268+
void WorkerPoolManager::GetStats(Store& output){
269+
270+
271+
m_job_queue->m_lock.lock();
272+
m_manager_args.stats_mtx.lock();
273+
274+
for(std::map<std::string, QueueStats>::iterator it = m_job_queue->m_stats.begin(); it!=m_job_queue->m_stats.end(); it++){
275+
276+
277+
output.Set( it->first + "_submitted", it->second.submitted);
278+
output.Set( it->first + "_queued", it->second.queued);
279+
output.Set( it->first + "_processing", m_manager_args.stats[it->first].processing);
280+
output.Set( it->first + "_completed", m_manager_args.stats[it->first].completed);
281+
output.Set( it->first + "_failed", m_manager_args.stats[it->first].failed);
282+
283+
}
284+
285+
m_manager_args.stats_mtx.unlock();
286+
m_job_queue->m_lock.unlock();
287+
288+
return;
289+
}
290+
268291
void WorkerPoolManager::PrintStats(){
269292

270293
printf("%s\n", GetStats().c_str());

src/DataModelBase/WorkerPoolManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ namespace ToolFramework{
127127
void ManageWorkers(); ///< Function to manage workers and distribute jobs to be run when unthreaded if you choose to not have the managment run on a thread.
128128
unsigned int NumThreads(); ///< Function to return the number of current worker threads
129129
std::string GetStats(); ///< Function to get the current stats
130+
void GetStats(Store& output); ///< Function to get the current stats
130131
void PrintStats(); ///< Function to print the current stats to screen
131132
void ClearStats(); ///< Function to clear the current stats
132133

0 commit comments

Comments
 (0)