36 #ifndef NEKTAR_LIB_UTILITIES_THREAD_H_
37 #define NEKTAR_LIB_UTILITIES_THREAD_H_
41 #include <boost/thread/mutex.hpp>
42 #include <boost/thread/locks.hpp>
43 #include <boost/thread/condition_variable.hpp>
44 #include <boost/thread/thread.hpp>
45 #include <boost/enable_shared_from_this.hpp>
48 #include <loki/Singleton.h>
324 typedef boost::unique_lock<boost::shared_mutex>
WriteLock;
325 typedef boost::shared_lock<boost::shared_mutex>
ReadLock;
388 virtual void QueueJobs(std::vector<ThreadJob*>& joblist);
401 virtual const std::string&
GetType()
const;
virtual unsigned int GetWorkerNum()
Returns the worker number of the executing thread.
int GetThrFromPartition(int pPartition)
virtual ~ThreadManager()
Destructor.
unsigned int GetWorkerNum()
virtual void SetNumWorkers()=0
Sets the number of active workers to the maximum.
virtual void Hold()=0
A calling threads holds until all active threads call this method.
virtual const std::string & GetType() const
Returns a description of the type of threading.
virtual void SetSchedType(SchedType s)=0
Sets the current scheduling algorithm.
void SetWorkerNum(unsigned int num)
Set number of worker threads.
virtual unsigned int GetMaxNumWorkers()
Gets the maximum available number of threads.
virtual void QueueJob(ThreadJob *job)=0
Pass a single job to the master queue.
virtual unsigned int GetNumWorkers()
Return the number of active workers.
virtual void Hold()
A calling threads holds until all active threads call this method.
ThreadManagerSharedPtr & GetInstance(const ThreadManagerName t)
Gets the ThreadManager associated with string s.
virtual void SetNumWorkers()
Sets the number of active workers to the maximum.
virtual void Wait()
Waits until all queued jobs are finished.
SchedType
Identifies the algorithm for scheduling.
boost::shared_lock< boost::shared_mutex > ReadLock
virtual unsigned int GetNumWorkers()=0
Return the number of active workers.
virtual ~ThreadStartupManager()
int GetPartitionFromRankThr(int pRank, unsigned int pThr)
ThreadJob()
Base constructor.
ThreadManagerFactory & GetThreadManagerFactory()
boost::unique_lock< boost::shared_mutex > WriteLock
#define LIB_UTILITIES_EXPORT
std::vector< ThreadManagerSharedPtr > m_threadManagers
std::string m_threadingType
ThreadStartupManager()
ThreadDefaultManager.
LibUtilities::NekFactory< std::string, ThreadManager, unsigned int > ThreadManagerFactory
int GetRankFromPartition(int pPartition)
virtual void QueueJob(ThreadJob *job)
Pass a single job to the master queue.
virtual void SetSchedType(SchedType s)
Sets the current scheduling algorithm.
ThreadMaster()
Constructor.
virtual const std::string & GetType() const =0
Returns a description of the type of threading.
ThreadMaster & GetThreadMaster()
virtual void QueueJobs(std::vector< ThreadJob * > &joblist)
Pass a list of tasklets to the master queue.
virtual unsigned int GetMaxNumWorkers()=0
Gets the maximum available number of threads.
virtual void SetChunkSize(unsigned int chnk)
Controls how many jobs are sent to each worker at a time.
boost::shared_mutex m_mutex
virtual void QueueJobs(std::vector< ThreadJob * > &joblist)=0
Pass a list of tasklets to the master queue.
ThreadManagerSharedPtr CreateInstance(const ThreadManagerName t, unsigned int nThr)
Creates an instance of a ThreadManager (which one is determined by a previous call to SetThreadingTyp...
Base class for tasks to be sent to the ThreadManager to run.
~ThreadMaster()
Destructor.
virtual bool InThread()=0
Indicates whether the code is in a worker thread or not.
virtual bool InThread()
Indicates whether the code is in a worker thread or not.
virtual bool IsInitialised()
ThreadManager implementation.
void SetThreadingType(const std::string &p_type)
Sets what ThreadManagers will be created in CreateInstance.
virtual ~ThreadJob()
Base destructor.
virtual void Wait()=0
Waits until all queued jobs are finished.
virtual unsigned int GetWorkerNum()=0
Returns the worker number of the executing thread.
The interface class for the controller for worker threads and jobs.
virtual bool IsInitialised()
ThreadManager implementation.
Provides a generic Factory class.
virtual void SetChunkSize(unsigned int chnk)=0
Controls how many jobs are sent to each worker at a time.
boost::shared_ptr< ThreadManager > ThreadManagerSharedPtr