Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends

SgThreadedWorker< I, O, W > Class Template Reference

#include <SgThreadedWorker.h>

List of all members.

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

Detailed Description

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

Definition at line 17 of file SgThreadedWorker.h.


Constructor & Destructor Documentation

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

Definition at line 87 of file SgThreadedWorker.h.

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

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

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 
)
template<typename I , typename O , typename W >
void SgThreadedWorker< I, O, W >::StartDoingWork (  )  [private]
template<typename I , typename O , typename W >
void SgThreadedWorker< I, O, W >::TellThreadsToQuit (  )  [private]
template<typename I , typename O , typename W >
void SgThreadedWorker< I, O, W >::WaitForThreadsToFinish (  )  [private]

Friends And Related Function Documentation

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

Definition at line 36 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 78 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 63 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 57 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 66 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]
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 69 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 72 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 60 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 75 of file SgThreadedWorker.h.

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


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


Sun Mar 13 2011 Doxygen 1.7.1