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);
Base class for tasks to be sent to the ThreadManager to run.
Implementation of ThreadManager using Boost threads.
boost::mutex m_masterQueueMutex
ThreadWorkerBoost ** m_threadList
virtual const std::string & GetType() const
Returns a description of the type of threading.
virtual unsigned int GetWorkerNum()
Returns the worker number of the executing thread.
virtual ~ThreadManagerBoost()
Shuts down threading.
virtual void QueueJob(ThreadJob *job)
Pass a single job to the master queue.
bool * m_threadActiveList
std::queue< ThreadJob * > m_masterQueue
boost::condition_variable m_masterQueueCondVar
virtual bool InThread()
Indicates whether the code is in a worker thread or not.
boost::thread::id m_masterThreadId
const unsigned int m_numThreads
virtual void SetNumWorkers()
Sets the number of active workers to the maximum.
static ThreadManagerSharedPtr Create(unsigned int numT)
Called by the factory method.
ThreadManagerBoost(const ThreadManagerBoost &)
virtual void Hold()
A calling threads holds until all active threads call this method.
std::map< boost::thread::id, unsigned int > m_threadMap
virtual unsigned int GetNumWorkers()
Return the number of active workers.
static std::string className
void SetNumWorkersImpl(const unsigned int num)
unsigned int m_numWorkers
boost::barrier * m_barrier
virtual unsigned int GetMaxNumWorkers()
Gets the maximum available number of threads.
boost::thread ** m_threadThreadList
boost::condition_variable m_masterActiveCondVar
virtual void SetChunkSize(unsigned int chnk)
Controls how many jobs are sent to each worker at a time.
virtual void QueueJobs(std::vector< ThreadJob * > &joblist)
Pass a list of tasklets to the master queue.
boost::mutex m_masterActiveMutex
virtual void SetSchedType(SchedType s)
Sets the current scheduling algorithm.
virtual void Wait()
Waits until all queued jobs are finished.
The interface class for the controller for worker threads and jobs.
Implementation class for ThreadManagerBoost.
ThreadWorkerBoost(const ThreadWorkerBoost &)
~ThreadWorkerBoost()
Destructor.
unsigned int GetWorkerNum()
Return the index of the worker thread.
void Stop()
A signal to shut down.
std::queue< ThreadJob * > m_workerQueue
void operator()()
This provides the interface that boost::thread uses to start the worker.
unsigned int GetNumToLoad()
ThreadManagerBoost * m_threadManager
SchedType
Identifies the algorithm for scheduling.
std::shared_ptr< ThreadManager > ThreadManagerSharedPtr
boost::unique_lock< boost::mutex > Lock
The above copyright notice and this permission notice shall be included.