00001 /* -*- mode: c++; c-basic-offset: 4; -*- */ 00002 #ifndef SENDS_SEDA_STAGE_HH 00003 #define SENDS_SEDA_STAGE_HH 00004 00005 #include "thread_pool.hh" 00006 #include "transaction.hh" 00007 00008 namespace sends { 00009 00022 class seda_stage : public thread_pool { 00023 public: 00027 struct stage_pars { 00029 int _debug; 00031 int _inq_capacity; 00033 int _threads; 00034 }; 00035 00036 public: 00044 seda_stage(int nThread, int nTrans=16); 00045 00049 virtual ~seda_stage(void); 00050 00055 int debug(void) const; 00056 00062 bool debug(int lvlmin) const; 00063 00069 virtual void filter(transaction* trans) = 0; 00070 00074 virtual void init_thread(void); 00075 00081 void link_output(seda_stage& pool); 00082 00088 void link_alternate(seda_stage& pool); 00089 00095 void put_output(transaction* trans); 00096 00102 void put_alternate(transaction* trans); 00103 00108 tran_queue& ref_input(void); 00109 00115 void reject(transaction* trans, const std::string& msg); 00116 00121 void set_debug(int lvl); 00122 00127 void set_parameters(const stage_pars& p); 00128 00140 virtual void shut(void); 00141 00147 virtual const char* stage_name(void) const = 0; 00148 00153 void start(void); 00154 00159 virtual void thread_entry(void); 00160 00161 private: 00162 int dbglvl; 00163 tran_queue input; 00164 tran_queue* output; 00165 tran_queue* alternate; 00166 long primary_count; 00167 long alternate_count; 00168 long reject_count; 00169 }; 00170 00171 //================================== Inline methods 00172 inline int 00173 seda_stage::debug(void) const { 00174 return dbglvl; 00175 } 00176 00177 inline bool 00178 seda_stage::debug(int minlvl) const { 00179 return dbglvl >= minlvl; 00180 } 00181 00182 inline tran_queue& 00183 seda_stage::ref_input(void) { 00184 return input; 00185 } 00186 00187 } 00188 00189 #endif // !defined(SENDS_SEDA_STAGE_HH)
1.5.5