31 bool runTask(
EProc ) {
36 unsigned long threadID()
const {
43 ostream &
operator<< (ostream &_stream,
const TTestTask &_task)
45 _stream << _task.threadID();
54 vector <TTestTask> tasksList(numTasks);
57 for (
size_t j = 0; j < 4; ++j )
59 cout <<
"+++++++++ Starting iteration #" << j <<
" ++++++++++++"<< endl;
60 for (
size_t i = 0; i < numTasks; ++i) {
64 cout <<
"\n ****** Drain the tasks queue ******" << endl;
67 cout <<
"\n Stopping..." << endl;
68 threadPool.
Stop(
true);
74 typedef map<unsigned long, size_t> counter_t;
77 vector <TTestTask>::const_iterator
iter = tasksList.begin();
78 vector <TTestTask>::const_iterator iter_end = tasksList.end();
79 for (; iter != iter_end; ++
iter) {
80 counter_t::iterator found = counter.find(iter->threadID());
81 if (found == counter.end())
82 counter.insert(counter_t::value_type(iter->threadID(), 1));
84 found->second = found->second + 1;
89 cout <<
"\n************* RESULT ****************" << endl;
91 counter_t::const_iterator
iter = counter.begin();
92 counter_t::const_iterator iter_end = counter.end();
94 for (; iter != iter_end; ++
iter) {
95 cout <<
"Thread " << iter->first <<
" was used " << iter->second <<
" times\n";
98 if (iter->second != g_multTasks)
102 cout <<
"ThreadPool: the simple test status: " << (testOK ?
"OK" :
"Failed") << endl;
RooArgList L(const RooAbsArg &v1)
std::map< std::string, std::string >::const_iterator iter
static Long_t SelfId()
Static method returning the id for the current thread.
void PushTask(typename TThreadPoolTask< aTask, aParam >::task_t &task, aParam param)
void threadPool(size_t _numThreads=10, bool _needDbg=false)
void Stop(bool processRemainingJobs=false)
void stressThreadPool(size_t _numThreads=5, bool _needDbg=false)
static Int_t Sleep(ULong_t secs, ULong_t nanos=0)
Static method to sleep the calling thread.
ostream & operator<<(ostream &_stream, const TTestTask &_task)