#include <SgThreadedWorker.h>
Classes | |
class | Thread |
Copyable object run in a boost::thread. More... | |
Public Member Functions | |
SgThreadedWorker (std::vector< W > &workers) | |
~SgThreadedWorker () | |
void | DoWork (const std::vector< I > &work, std::vector< std::pair< I, O > > &output) |
Private Member Functions | |
void | StartDoingWork () |
void | WaitForThreadsToFinish () |
void | TellThreadsToQuit () |
Private Attributes | |
bool | m_quit |
Flag telling threads to exit. | |
boost::mutex | m_workMutex |
Threads must lock this mutex before getting work from list. | |
boost::mutex | m_outputMutex |
Threads must lock this mutex before updating output. | |
boost::barrier | m_startWork |
Threads block on this barrier until told to start. | |
boost::barrier | m_workFinished |
Threads block on this barrier until all are finished. | |
std::size_t | m_workIndex |
Index of next problem to solve. | |
const std::vector< I > * | m_workToDo |
Problems to solve. | |
std::vector< std::pair< I, O > > * | m_output |
Solved problems. | |
std::vector< boost::shared_ptr < boost::thread > > | m_threads |
The threads. | |
Friends | |
class | Thread |
Definition at line 17 of file SgThreadedWorker.h.
SgThreadedWorker< I, O, W >::SgThreadedWorker | ( | std::vector< W > & | workers | ) |
Definition at line 87 of file SgThreadedWorker.h.
References SgThreadedWorker< I, O, W >::m_threads.
SgThreadedWorker< I, O, W >::~SgThreadedWorker | ( | ) |
Definition at line 101 of file SgThreadedWorker.h.
References SgThreadedWorker< I, O, W >::m_threads, SgDebug(), and SgThreadedWorker< I, O, W >::TellThreadsToQuit().
void SgThreadedWorker< I, O, W >::DoWork | ( | const std::vector< I > & | work, | |
std::vector< std::pair< I, O > > & | output | |||
) |
Definition at line 112 of file SgThreadedWorker.h.
References SgThreadedWorker< I, O, W >::m_output, SgThreadedWorker< I, O, W >::m_workIndex, SgThreadedWorker< I, O, W >::m_workToDo, SgDebug(), SgThreadedWorker< I, O, W >::StartDoingWork(), and SgThreadedWorker< I, O, W >::WaitForThreadsToFinish().
void SgThreadedWorker< I, O, W >::StartDoingWork | ( | ) | [private] |
Definition at line 168 of file SgThreadedWorker.h.
References SgThreadedWorker< I, O, W >::m_startWork.
Referenced by SgThreadedWorker< I, O, W >::DoWork().
void SgThreadedWorker< I, O, W >::TellThreadsToQuit | ( | ) | [private] |
Definition at line 180 of file SgThreadedWorker.h.
References SgThreadedWorker< I, O, W >::m_quit, and SgThreadedWorker< I, O, W >::m_startWork.
Referenced by SgThreadedWorker< I, O, W >::~SgThreadedWorker().
void SgThreadedWorker< I, O, W >::WaitForThreadsToFinish | ( | ) | [private] |
Definition at line 174 of file SgThreadedWorker.h.
References SgThreadedWorker< I, O, W >::m_workFinished.
Referenced by SgThreadedWorker< I, O, W >::DoWork().
friend class Thread [friend] |
Definition at line 36 of file SgThreadedWorker.h.
std::vector<std::pair<I,O> >* SgThreadedWorker< I, O, W >::m_output [private] |
Solved problems.
Definition at line 78 of file SgThreadedWorker.h.
Referenced by SgThreadedWorker< I, O, W >::DoWork().
boost::mutex SgThreadedWorker< I, O, W >::m_outputMutex [private] |
Threads must lock this mutex before updating output.
Definition at line 63 of file SgThreadedWorker.h.
bool SgThreadedWorker< I, O, W >::m_quit [private] |
Flag telling threads to exit.
Definition at line 57 of file SgThreadedWorker.h.
Referenced by SgThreadedWorker< I, O, W >::TellThreadsToQuit().
boost::barrier SgThreadedWorker< I, O, W >::m_startWork [private] |
Threads block on this barrier until told to start.
Definition at line 66 of file SgThreadedWorker.h.
Referenced by SgThreadedWorker< I, O, W >::StartDoingWork(), and SgThreadedWorker< I, O, W >::TellThreadsToQuit().
std::vector<boost::shared_ptr<boost::thread> > SgThreadedWorker< I, O, W >::m_threads [private] |
The threads.
Definition at line 81 of file SgThreadedWorker.h.
Referenced by SgThreadedWorker< I, O, W >::SgThreadedWorker(), and SgThreadedWorker< I, O, W >::~SgThreadedWorker().
boost::barrier SgThreadedWorker< I, O, W >::m_workFinished [private] |
Threads block on this barrier until all are finished.
Definition at line 69 of file SgThreadedWorker.h.
Referenced by SgThreadedWorker< I, O, W >::WaitForThreadsToFinish().
std::size_t SgThreadedWorker< I, O, W >::m_workIndex [private] |
Index of next problem to solve.
Definition at line 72 of file SgThreadedWorker.h.
Referenced by SgThreadedWorker< I, O, W >::DoWork().
boost::mutex SgThreadedWorker< I, O, W >::m_workMutex [private] |
Threads must lock this mutex before getting work from list.
Definition at line 60 of file SgThreadedWorker.h.
const std::vector<I>* SgThreadedWorker< I, O, W >::m_workToDo [private] |
Problems to solve.
Definition at line 75 of file SgThreadedWorker.h.
Referenced by SgThreadedWorker< I, O, W >::DoWork().