35 #ifndef NEKTAR_LIBUTILITIES_THREADBOOST_H_ 36 #define NEKTAR_LIBUTILITIES_THREADBOOST_H_ 42 #include <boost/thread/barrier.hpp> 51 typedef boost::unique_lock<boost::mutex>
Lock;
70 virtual void QueueJobs(std::vector<ThreadJob*>& joblist);
82 virtual const std::string&
GetType()
const;
88 return std::shared_ptr<ThreadManager>(
131 unsigned int workerNum);
149 void Stop() { m_keepgoing =
false;} ;
156 unsigned int GetNumToLoad();
157 void WaitForActive();
virtual bool InThread()
Indicates whether the code is in a worker thread or not.
virtual unsigned int GetMaxNumWorkers()
Gets the maximum available number of threads.
ThreadManagerBoost * m_threadManager
boost::thread::id m_masterThreadId
boost::mutex m_masterQueueMutex
std::shared_ptr< ThreadManager > ThreadManagerSharedPtr
std::queue< ThreadJob * > m_workerQueue
const unsigned int m_numThreads
virtual void Wait()
Waits until all queued jobs are finished.
virtual void SetSchedType(SchedType s)
Sets the current scheduling algorithm.
friend class ThreadWorkerBoost
virtual unsigned int GetWorkerNum()
Returns the worker number of the executing thread.
boost::condition_variable m_masterQueueCondVar
boost::mutex m_masterActiveMutex
std::map< boost::thread::id, unsigned int > m_threadMap
void operator()()
This provides the interface that boost::thread uses to start the worker.
SchedType
Identifies the algorithm for scheduling.
virtual void QueueJob(ThreadJob *job)
Pass a single job to the master queue.
virtual void Hold()
A calling threads holds until all active threads call this method.
virtual void QueueJobs(std::vector< ThreadJob *> &joblist)
Pass a list of tasklets to the master queue.
virtual void SetNumWorkers()
Sets the number of active workers to the maximum.
boost::thread ** m_threadThreadList
virtual ~ThreadManagerBoost()
Shuts down threading.
unsigned int GetWorkerNum()
Return the index of the worker thread.
unsigned int m_numWorkers
void Stop()
A signal to shut down.
boost::barrier * m_barrier
static ThreadManagerSharedPtr Create(unsigned int numT)
Called by the factory method.
virtual void SetChunkSize(unsigned int chnk)
Controls how many jobs are sent to each worker at a time.
Base class for tasks to be sent to the ThreadManager to run.
static std::string className
Implementation class for ThreadManagerBoost.
void SetNumWorkersImpl(const unsigned int num)
virtual unsigned int GetNumWorkers()
Return the number of active workers.
bool * m_threadActiveList
std::queue< ThreadJob * > m_masterQueue
virtual const std::string & GetType() const
Returns a description of the type of threading.
The interface class for the controller for worker threads and jobs.
ThreadWorkerBoost ** m_threadList
Implementation of ThreadManager using Boost threads.
boost::condition_variable m_masterActiveCondVar
boost::unique_lock< boost::mutex > Lock