Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgThreadedWorker< I, O, W > Class Template Reference

#include <SgThreadedWorker.h>

List of all members.


Detailed Description

template<typename I, typename O, typename W>
class SgThreadedWorker< I, O, W >

Definition at line 18 of file SgThreadedWorker.h.

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

Classes

class  Thread
 Copyable object run in a boost::thread. More...


Constructor & Destructor Documentation

template<typename I, typename O, typename W>
SgThreadedWorker< I, O, W >::SgThreadedWorker ( std::vector< W > &  workers  ) 

Definition at line 88 of file SgThreadedWorker.h.

References SgThreadedWorker< I, O, W >::m_threads.

template<typename I, typename O, typename W>
SgThreadedWorker< I, O, W >::~SgThreadedWorker (  ) 

Definition at line 102 of file SgThreadedWorker.h.

References SgThreadedWorker< I, O, W >::m_threads, SgDebug(), and SgThreadedWorker< I, O, W >::TellThreadsToQuit().


Member Function Documentation

template<typename I, typename O, typename W>
void SgThreadedWorker< I, O, W >::DoWork ( const std::vector< I > &  work,
std::vector< std::pair< I, O > > &  output 
)

Definition at line 113 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().

template<typename I, typename O, typename W>
void SgThreadedWorker< I, O, W >::StartDoingWork (  )  [private]

Definition at line 169 of file SgThreadedWorker.h.

References SgThreadedWorker< I, O, W >::m_startWork.

Referenced by SgThreadedWorker< I, O, W >::DoWork().

template<typename I, typename O, typename W>
void SgThreadedWorker< I, O, W >::TellThreadsToQuit (  )  [private]

Definition at line 181 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().

template<typename I, typename O, typename W>
void SgThreadedWorker< I, O, W >::WaitForThreadsToFinish (  )  [private]

Definition at line 175 of file SgThreadedWorker.h.

References SgThreadedWorker< I, O, W >::m_workFinished.

Referenced by SgThreadedWorker< I, O, W >::DoWork().


Friends And Related Function Documentation

template<typename I, typename O, typename W>
friend class Thread [friend]

Definition at line 37 of file SgThreadedWorker.h.


Member Data Documentation

template<typename I, typename O, typename W>
std::vector<std::pair<I,O> >* SgThreadedWorker< I, O, W >::m_output [private]

Solved problems.

Definition at line 79 of file SgThreadedWorker.h.

Referenced by SgThreadedWorker< I, O, W >::DoWork().

template<typename I, typename O, typename W>
boost::mutex SgThreadedWorker< I, O, W >::m_outputMutex [private]

Threads must lock this mutex before updating output.

Definition at line 64 of file SgThreadedWorker.h.

template<typename I, typename O, typename W>
bool SgThreadedWorker< I, O, W >::m_quit [private]

Flag telling threads to exit.

Definition at line 58 of file SgThreadedWorker.h.

Referenced by SgThreadedWorker< I, O, W >::TellThreadsToQuit().

template<typename I, typename O, typename W>
boost::barrier SgThreadedWorker< I, O, W >::m_startWork [private]

Threads block on this barrier until told to start.

Definition at line 67 of file SgThreadedWorker.h.

Referenced by SgThreadedWorker< I, O, W >::StartDoingWork(), and SgThreadedWorker< I, O, W >::TellThreadsToQuit().

template<typename I, typename O, typename W>
std::vector<boost::shared_ptr<boost::thread> > SgThreadedWorker< I, O, W >::m_threads [private]

The threads.

Definition at line 82 of file SgThreadedWorker.h.

Referenced by SgThreadedWorker< I, O, W >::SgThreadedWorker(), and SgThreadedWorker< I, O, W >::~SgThreadedWorker().

template<typename I, typename O, typename W>
boost::barrier SgThreadedWorker< I, O, W >::m_workFinished [private]

Threads block on this barrier until all are finished.

Definition at line 70 of file SgThreadedWorker.h.

Referenced by SgThreadedWorker< I, O, W >::WaitForThreadsToFinish().

template<typename I, typename O, typename W>
std::size_t SgThreadedWorker< I, O, W >::m_workIndex [private]

Index of next problem to solve.

Definition at line 73 of file SgThreadedWorker.h.

Referenced by SgThreadedWorker< I, O, W >::DoWork().

template<typename I, typename O, typename W>
boost::mutex SgThreadedWorker< I, O, W >::m_workMutex [private]

Threads must lock this mutex before getting work from list.

Definition at line 61 of file SgThreadedWorker.h.

template<typename I, typename O, typename W>
const std::vector<I>* SgThreadedWorker< I, O, W >::m_workToDo [private]

Problems to solve.

Definition at line 76 of file SgThreadedWorker.h.

Referenced by SgThreadedWorker< I, O, W >::DoWork().


The documentation for this class was generated from the following file:


17 Jun 2010 Doxygen 1.4.7