mb_runtime_thread_per_block.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2007 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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  * \brief Concrete runtime that uses a thread per mblock
00031  * \internal
00032  *
00033  * These are all implementation details.
00034  */
00035 class mb_runtime_thread_per_block : public mb_runtime_base
00036 {
00037 public:
00038   omni_mutex                  d_workers_mutex;  // hold while manipulating d_workers
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 /* INCLUDED_MB_RUNTIME_THREAD_PER_BLOCK_H */

Generated by  doxygen 1.6.2