Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef INCLUDED_MB_RUNTIME_THREAD_PER_BLOCK_H
00022 #define INCLUDED_MB_RUNTIME_THREAD_PER_BLOCK_H
00023
00024 #include <mb_runtime_base.h>
00025 #include <mb_worker.h>
00026 #include <mblock/msg_queue.h>
00027 #include <mb_timer_queue.h>
00028
00029
00030
00031
00032
00033
00034
00035 class mb_runtime_thread_per_block : public mb_runtime_base
00036 {
00037 public:
00038 omni_mutex d_workers_mutex;
00039 std::vector<mb_worker*> d_workers;
00040 bool d_shutdown_in_progress;
00041 pmt_t d_shutdown_result;
00042 mb_msg_queue d_msgq;
00043 mb_timer_queue d_timer_queue;
00044
00045 typedef std::vector<mb_worker*>::iterator worker_iter_t;
00046
00047 mb_runtime_thread_per_block();
00048 ~mb_runtime_thread_per_block();
00049
00050 bool run(const std::string &instance_name,
00051 const std::string &class_name,
00052 pmt_t user_arg,
00053 pmt_t *result);
00054
00055 void request_shutdown(pmt_t result);
00056
00057 protected:
00058 mb_mblock_sptr
00059 create_component(const std::string &instance_name,
00060 const std::string &class_name,
00061 pmt_t user_arg);
00062
00063 pmt_t
00064 schedule_one_shot_timeout(const mb_time &abs_time, pmt_t user_data,
00065 mb_msg_accepter_sptr accepter);
00066
00067 pmt_t
00068 schedule_periodic_timeout(const mb_time &first_abs_time,
00069 const mb_time &delta_time,
00070 pmt_t user_data,
00071 mb_msg_accepter_sptr accepter);
00072 void
00073 cancel_timeout(pmt_t handle);
00074
00075 private:
00076 void reap_dead_workers();
00077 void run_loop();
00078
00079 void send_all_sys_msg(pmt_t signal, pmt_t data = PMT_F,
00080 pmt_t metadata = PMT_F,
00081 mb_pri_t priority = MB_PRI_BEST);
00082 };
00083
00084 #endif