Nektar++
|
Implementation class for ThreadManagerStd. More...
#include <ThreadStd.h>
Public Member Functions | |
ThreadWorkerStd (ThreadManagerStd *threadManager, unsigned int workerNum) | |
Constructor. More... | |
~ThreadWorkerStd () | |
Destructor. More... | |
void | operator() () |
This provides the interface that std::thread uses to start the worker. More... | |
unsigned int | GetWorkerNum () |
Return the index of the worker thread. More... | |
void | Stop () |
A signal to shut down. More... | |
Private Member Functions | |
ThreadWorkerStd () | |
ThreadWorkerStd (const ThreadWorkerStd &) | |
void | MainLoop () |
void | LoadJobs () |
unsigned int | GetNumToLoad () |
void | WaitForActive () |
void | RunJobs () |
Private Attributes | |
ThreadManagerStd * | m_threadManager |
std::queue< ThreadJob * > | m_workerQueue |
bool | m_keepgoing |
unsigned int | m_threadNum |
Implementation class for ThreadManagerStd.
Each instance of this class corresponds to a worker thread. Instances manage their own queue of jobs to run, grabbing new jobs from the master queue when it is exhausted.
Definition at line 158 of file ThreadStd.h.
Nektar::Thread::ThreadWorkerStd::ThreadWorkerStd | ( | ThreadManagerStd * | tm, |
unsigned int | workerNum | ||
) |
Constructor.
threadManager | Pointer to the ThreadManagerStd that is controlling this worker. |
workerNum | Unique number from 0..(number_of_threads - 1) |
Called by the ThreadManagerStd instance.
Definition at line 312 of file ThreadStd.cpp.
Nektar::Thread::ThreadWorkerStd::~ThreadWorkerStd | ( | ) |
Destructor.
Winds up this thread's execution. Jobs in its queue are lost.
Definition at line 322 of file ThreadStd.cpp.
References m_keepgoing, and m_threadNum.
|
private |
|
private |
|
private |
Definition at line 370 of file ThreadStd.cpp.
References Nektar::Thread::e_dynamic, Nektar::Thread::e_guided, Nektar::ErrorUtil::efatal, Nektar::Thread::ThreadManagerStd::m_chunkSize, Nektar::Thread::ThreadManagerStd::m_masterQueue, Nektar::Thread::ThreadManagerStd::m_numWorkers, Nektar::Thread::ThreadManagerStd::m_schedType, m_threadManager, and NEKERROR.
Referenced by LoadJobs().
|
inline |
Return the index of the worker thread.
Definition at line 175 of file ThreadStd.h.
References m_threadNum.
|
private |
Definition at line 336 of file ThreadStd.cpp.
References GetNumToLoad(), m_keepgoing, Nektar::Thread::ThreadManagerStd::m_masterActiveMutex, Nektar::Thread::ThreadManagerStd::m_masterQueue, Nektar::Thread::ThreadManagerStd::m_masterQueueCondVar, Nektar::Thread::ThreadManagerStd::m_masterQueueMutex, Nektar::Thread::ThreadManagerStd::m_threadActiveList, Nektar::Thread::ThreadManagerStd::m_threadBusyList, m_threadManager, m_threadNum, and m_workerQueue.
Referenced by MainLoop().
|
private |
Definition at line 412 of file ThreadStd.cpp.
References LoadJobs(), m_keepgoing, RunJobs(), and WaitForActive().
Referenced by operator()().
|
inline |
This provides the interface that std::thread uses to start the worker.
Definition at line 166 of file ThreadStd.h.
References MainLoop().
|
private |
Definition at line 425 of file ThreadStd.cpp.
References m_keepgoing, m_threadNum, m_workerQueue, Nektar::Thread::ThreadJob::Run(), and Nektar::Thread::ThreadJob::SetWorkerNum().
Referenced by MainLoop().
|
inline |
A signal to shut down.
If this method is called the worker will shut down. Used by the ThreadManagerStd to stop threading.
Definition at line 185 of file ThreadStd.h.
References m_keepgoing.
Referenced by Nektar::Thread::ThreadManagerStd::~ThreadManagerStd().
|
private |
Definition at line 397 of file ThreadStd.cpp.
References m_keepgoing, Nektar::Thread::ThreadManagerStd::m_masterActiveCondVar, Nektar::Thread::ThreadManagerStd::m_masterActiveMutex, Nektar::Thread::ThreadManagerStd::m_threadActiveList, m_threadManager, and m_threadNum.
Referenced by MainLoop().
|
private |
Definition at line 202 of file ThreadStd.h.
Referenced by LoadJobs(), MainLoop(), RunJobs(), Stop(), WaitForActive(), and ~ThreadWorkerStd().
|
private |
Definition at line 200 of file ThreadStd.h.
Referenced by GetNumToLoad(), LoadJobs(), and WaitForActive().
|
private |
Definition at line 203 of file ThreadStd.h.
Referenced by GetWorkerNum(), LoadJobs(), RunJobs(), WaitForActive(), and ~ThreadWorkerStd().
|
private |
Definition at line 201 of file ThreadStd.h.
Referenced by LoadJobs(), and RunJobs().