CVD 0.8
|
00001 #ifndef CVD_INCLUDE_RUNNABLE_BATCH_H 00002 #define CVD_INCLUDE_RUNNABLE_BATCH_H 00003 00004 #include <cvd/runnable.h> 00005 #if defined WIN32 && !defined __MINGW32__ 00006 #include <memory> 00007 #else 00008 #include <tr1/memory> 00009 #endif 00010 #include <vector> 00011 namespace CVD 00012 { 00013 //Why couldn't VS put TR1in the correct namespace? 00014 namespace tr1 00015 { 00016 using namespace std; 00017 using namespace std::tr1; 00018 } 00019 00020 class Thread; 00021 00022 //Forward declaration 00023 template<class C> class MessageQueue; 00024 00029 class RunnableBatch 00030 { 00031 private: 00032 bool joined; 00033 unsigned int parallelism; 00034 00035 class RunMessageInThread; 00036 00037 std::vector<CVD::tr1::shared_ptr<RunMessageInThread> > threads; 00038 CVD::tr1::shared_ptr<MessageQueue<CVD::tr1::shared_ptr<Runnable> > > queue; 00039 00040 00041 public: 00049 RunnableBatch(unsigned int p); 00050 00053 void join(); 00054 00058 void schedule(CVD::tr1::shared_ptr<Runnable> r); 00059 00062 ~RunnableBatch(); 00063 }; 00064 00065 } 00066 #endif