Go to the documentation of this file.00001
00007 #ifndef THREAD_H_
00008 #define THREAD_H_
00009
00010 #include <vector>
00011 #include <boost/thread.hpp>
00012 #include "tractography.h"
00013
00014 typedef std::vector<int> WorkList ;
00015 typedef std::vector<WorkList> WorkDistribution ;
00016
00021 class Thread
00022 {
00023 public:
00024 Thread() {}
00025 virtual void operator()() = 0 ;
00026 virtual ~Thread() = 0 ;
00027 } ;
00028
00029
00034 class TractographyThread: public Thread
00035 {
00036 protected:
00037 const WorkList& work_list_ ;
00038 int index_ ;
00039 mutable boost::mutex index_mutex_ ;
00040 int id_ ;
00041 Tractography *tractography_ ;
00042 std::vector<SeedPointInfo>& seed_infos_ ;
00043 bool branching_ ;
00044 int num_tensors_ ;
00045 std::vector<Fiber>& output_fiber_group_ ;
00046 public:
00047 TractographyThread( const WorkList& work_list,
00048 const int id,
00049 Tractography *tractography,
00050 std::vector<SeedPointInfo>& seed_infos,
00051 bool branching,
00052 int num_tensors,
00053 std::vector<Fiber>& output_fiber_group
00054 ) ;
00055 int get_num_works() const ;
00056 int get_index() const ;
00057 int get_id() const ;
00058 void lock_index() const ;
00059 void operator()() ;
00060 ~TractographyThread() ;
00061 public:
00062 std::vector<SeedPointInfo> branching_seed_info_ ;
00063 std::vector<BranchingSeedAffiliation> branching_seed_affiliation_ ;
00064 } ;
00065
00070 class ProgressThread: public Thread
00071 {
00072 protected:
00073 const std::vector<TractographyThread *>& work_threads_ ;
00074 public:
00075 ProgressThread(const std::vector<TractographyThread *>& work_threads) ;
00076 void operator()() ;
00077 ~ProgressThread() ;
00078 } ;
00079
00080 const int PROGRESS_REPORT_INTERVAL = 2 ;
00081
00082 WorkDistribution GenerateWorkDistribution(const int num_threads, const int total_num_works) ;
00083
00084 #endif