12#ifndef ROOT_TThreadPool 
   13#define ROOT_TThreadPool 
   34#define sleep(s) _sleep(s) 
   72template <
class aTask, 
class aParam>
 
   75   bool run(aParam ¶m) {
 
   77      return pThis->runTask(param);
 
 
 
   89template <
class aTask, 
class aParam>
 
  118template <
class aTask, 
class aParam>
 
  153      threads_array_t::const_iterator iter = 
fThreads.begin();
 
 
  175         DbgLog(
"Main thread. Try to push a task");
 
  182         DbgLog(
"Main thread. the task is pushed");
 
 
  197            DbgLog(
"Main thread is waiting");
 
  199            DbgLog(
"Main thread is DONE waiting");
 
  207         DbgLog(
"Main threads requests to STOP");
 
 
  240      while (
true && !
pThis->fStopped) {
 
  241         std::stringstream 
ss;
 
  243               << 
">>>> Check for tasks." 
  244               << 
" Number of Tasks: " << 
pThis->fTasks.size()
 
  245               << 
"; Idle threads: " << 
pThis->IdleThreads();
 
 
  255      while (!
pThis->fStopped) {
 
  262            if (
pThis->fTasks.empty() && !
pThis->fStopped) {
 
  263               pThis->DbgLog(
"waiting for a task");
 
  265               if (
pThis->fThreads.size() == 
pThis->fIdleThreads) {
 
  267                  pThis->fAllTasksDone->Broadcast();
 
  271               pThis->fThreadNeeded->Wait();
 
  273               pThis->DbgLog(
"done waiting for tasks");
 
  279            if (!
pThis->fTasks.empty()) {
 
  280               --
pThis->fIdleThreads;
 
  284               pThis->DbgLog(
"get the task");
 
  285            } 
else if (
pThis->fThreads.size() == 
pThis->fIdleThreads) {
 
  287               pThis->fAllTasksDone->Broadcast();
 
  289            pThis->DbgLog(
"done Check <<<<");
 
  294            pThis->DbgLog(
"Run the task");
 
  298               ++
pThis->fSuccessfulTasks;
 
  304            ++
pThis->fIdleThreads;
 
  306            pThis->DbgLog(
"Done Running the task");
 
  310         pThis->fThreadAvailable->Broadcast();
 
  313      pThis->DbgLog(
"**** DONE ***");
 
 
  319      threads_array_t::const_iterator iter = 
pThis->fThreads.
begin();
 
 
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
R__EXTERN C unsigned int sleep(unsigned int seconds)
 
const_iterator begin() const
 
const_iterator end() const
 
Int_t Wait()
Wait to be signaled.
 
const TNonCopyable & operator=(const TNonCopyable &)
 
TNonCopyable(const TNonCopyable &)
 
TThreadPoolTask(task_t &task, aParam ¶m)
 
TThreadPoolTaskImp< aTask, aParam > task_t
 
TThreadPool(size_t threadsCount, bool needDbg=false)
 
TThreadPoolTask< aTask, aParam > task_t
 
TCondition * fThreadAvailable
 
size_t TasksCount() const
 
TMutex fMutexAllTasksDone
 
void Stop(bool processRemainingJobs=false)
 
TThread * fThreadJoinHelper
 
TCondition * fAllTasksDone
 
static void * Executor(void *arg)
 
static bool IsThreadActive(TThread *pThread)
 
static void * JoinHelper(void *arg)
 
void DbgLog(const std::string &msg)
 
static void * Monitor(void *arg)
 
TCondition * fThreadNeeded
 
size_t IdleThreads() const
 
void PushTask(typename TThreadPoolTask< aTask, aParam >::task_t &task, aParam param)
 
size_t SuccessfulTasks() const
 
std::vector< TThread * > threads_array_t
 
std::queue< task_t * > taskqueue_t
 
<div class="legacybox"><h2>Legacy Code</h2> TThread is a legacy interface: there will be no bug fixes...
 
Long_t Join(void **ret=nullptr)
Join this thread.
 
static Long_t SelfId()
Static method returning the id for the current thread.
 
Int_t Run(void *arg=nullptr, const int affinity=-1)
Start the thread.