48 "Threading using std::thread.");
55 : m_numThreads(numT), m_numWorkers(numT), m_masterQueue(),
56 m_masterQueueMutex(), m_masterActiveMutex(), m_masterQueueCondVar(),
57 m_masterActiveCondVar(), m_chunkSize(1), m_schedType(
e_dynamic),
70 cerr <<
"Exception while allocating thread storage: " << e.what()
84 cerr <<
"Exception while allocating worker threads: " << e.what()
101 std::cerr <<
"Exception while creating worker threads" << std::endl;
108 m_type =
"Threading with Std";
145 std::vector<ThreadJob *>::iterator it;
146 for (it = joblist.begin(); it < joblist.end(); ++it)
167 bool working =
false;
199 std::thread::id
id = std::this_thread::get_id();
235 std::thread::id
id = std::this_thread::get_id();
269 n = std::max(n,
static_cast<unsigned int>(0));
313 : m_threadManager(tm), m_workerQueue(), m_keepgoing(true),
314 m_threadNum(workerNum)
326 std::cerr <<
"Warning: ThreadWorker: " <<
m_threadNum
327 <<
"destroyed while running!" << std::endl;
372 unsigned int numToLoad = 0;
376 numToLoad = std::max(
378 static_cast<unsigned long>(
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Base class for tasks to be sent to the ThreadManager to run.
void SetWorkerNum(unsigned int num)
Set number of worker threads.
void QueueJob(ThreadJob *job)
Pass a single job to the master queue.
Lightweight barrier class.
Implementation of ThreadManager using std::thread.
void v_SetSchedType(SchedType s) override
~ThreadManagerStd() override
Shuts down threading.
const std::string & v_GetType() const override
unsigned int m_numWorkers
bool * m_threadActiveList
std::map< std::thread::id, unsigned int > m_threadMap
void v_QueueJob(ThreadJob *job) override
ThreadWorkerStd ** m_threadList
void v_QueueJobs(std::vector< ThreadJob * > &joblist) override
static ThreadManagerSharedPtr Create(unsigned int numT)
Called by the factory method.
bool v_InThread() override
std::thread ** m_threadThreadList
friend class ThreadWorkerStd
std::mutex m_masterActiveMutex
std::mutex m_masterQueueMutex
std::thread::id m_masterThreadId
unsigned int v_GetNumWorkers() override
const unsigned int m_numThreads
void v_SetNumWorkers() override
std::queue< ThreadJob * > m_masterQueue
std::condition_variable m_masterQueueCondVar
std::condition_variable m_masterActiveCondVar
void SetNumWorkersImpl(const unsigned int num)
unsigned int v_GetMaxNumWorkers() override
void v_SetChunkSize(unsigned int chnk) override
unsigned int v_GetWorkerNum() override
static std::string className
Implementation class for ThreadManagerStd.
std::queue< ThreadJob * > m_workerQueue
ThreadManagerStd * m_threadManager
~ThreadWorkerStd()
Destructor.
void Stop()
A signal to shut down.
unsigned int GetNumToLoad()
std::unique_lock< std::mutex > Lock
SchedType
Identifies the algorithm for scheduling.
ThreadManagerFactory & GetThreadManagerFactory()