36 #ifndef NEKTAR_LIBUTILITIES_THREADBOOST_H_
37 #define NEKTAR_LIBUTILITIES_THREADBOOST_H_
43 #include <boost/thread/barrier.hpp>
52 typedef boost::unique_lock<boost::mutex>
Lock;
71 virtual void QueueJobs(std::vector<ThreadJob*>& joblist);
83 virtual const std::string&
GetType()
const;
89 return boost::shared_ptr<ThreadManager>(
132 unsigned int workerNum);
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::queue< ThreadJob * > m_workerQueue
~ThreadWorkerBoost()
Destructor.
const unsigned int m_numThreads
virtual void Wait()
Waits until all queued jobs are finished.
virtual const std::string & GetType() const
Returns a description of the type of threading.
virtual void SetSchedType(SchedType s)
Sets the current scheduling algorithm.
virtual unsigned int GetWorkerNum()
Returns the worker number of the executing thread.
boost::condition_variable m_masterQueueCondVar
virtual void QueueJobs(std::vector< ThreadJob * > &joblist)
Pass a list of tasklets to the master queue.
unsigned int GetNumToLoad()
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 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
static boost::mutex mutex
std::queue< ThreadJob * > m_masterQueue
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
boost::shared_ptr< ThreadManager > ThreadManagerSharedPtr