Imported Upstream version 3.2.2
[debian/gnuradio] / mblock / src / lib / mb_runtime_base.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef INCLUDED_MB_RUNTIME_BASE_H
23 #define INCLUDED_MB_RUNTIME_BASE_H
24
25 #include <mblock/runtime.h>
26 #include <gnuradio/omnithread.h>
27 #include <mblock/time.h>
28
29 /*
30  * \brief This is the runtime class used by the implementation.
31  */
32 class mb_runtime_base : public mb_runtime
33 {
34   omni_mutex            d_brl;  // big runtime lock (avoid using this if possible...)
35
36 protected:
37   mb_msg_accepter_sptr  d_accepter;
38
39 public:
40
41   /*!
42    * \brief lock the big runtime lock
43    * \internal
44    */
45   inline void lock() { d_brl.lock(); }
46
47   /*!
48    * \brief unlock the big runtime lock
49    * \internal
50    */
51   inline void unlock() { d_brl.unlock(); }
52
53   virtual void request_shutdown(pmt_t result);
54
55   virtual mb_mblock_sptr
56   create_component(const std::string &instance_name,
57                    const std::string &class_name,
58                    pmt_t user_arg) = 0;
59
60   virtual pmt_t
61   schedule_one_shot_timeout(const mb_time &abs_time, pmt_t user_data,
62                             mb_msg_accepter_sptr accepter);
63
64   virtual pmt_t
65   schedule_periodic_timeout(const mb_time &first_abs_time,
66                             const mb_time &delta_time,
67                             pmt_t user_data,
68                             mb_msg_accepter_sptr accepter);
69   virtual void
70   cancel_timeout(pmt_t handle);
71
72   mb_msg_accepter_sptr
73   accepter() { return d_accepter; }
74   
75 };
76
77
78 #endif /* INCLUDED_MB_RUNTIME_BASE_H */