GNU Radio Manual and C++ API Reference  3.8.1.0
The Free & Open Software Radio Ecosystem
tpb_detail.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008,2009,2013 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_GR_TPB_DETAIL_H
23 #define INCLUDED_GR_TPB_DETAIL_H
24 
25 #include <gnuradio/api.h>
26 #include <gnuradio/thread/thread.h>
27 #include <pmt/pmt.h>
28 #include <deque>
29 
30 namespace gr {
31 
32 class block_detail;
33 
34 /*!
35  * \brief used by thread-per-block scheduler
36  */
38  gr::thread::mutex mutex; //< protects all vars
43 
44 public:
45  tpb_detail() : input_changed(false), output_changed(false) {}
46 
47  //! Called by us to tell all our upstream blocks that their output
48  //! may have changed.
49  void notify_upstream(block_detail* d);
50 
51  //! Called by us to tell all our downstream blocks that their
52  //! input may have changed.
53  void notify_downstream(block_detail* d);
54 
55  //! Called by us to notify both upstream and downstream
56  void notify_neighbors(block_detail* d);
57 
58  //! Called by pmt msg posters
59  void notify_msg()
60  {
61  gr::thread::scoped_lock guard(mutex);
62  input_changed = true;
63  input_cond.notify_one();
64  output_changed = true;
65  output_cond.notify_one();
66  }
67 
68  //! Called by us
70  {
71  gr::thread::scoped_lock guard(mutex);
72  input_changed = false;
73  output_changed = false;
74  }
75 
76 private:
77  //! Used by notify_downstream
78  void set_input_changed()
79  {
80  gr::thread::scoped_lock guard(mutex);
81  input_changed = true;
82  input_cond.notify_one();
83  }
84 
85  //! Used by notify_upstream
86  void set_output_changed()
87  {
88  gr::thread::scoped_lock guard(mutex);
89  output_changed = true;
90  output_cond.notify_one();
91  }
92 };
93 
94 } /* namespace gr */
95 
96 #endif /* INCLUDED_GR_TPB_DETAIL_H */
boost::unique_lock< boost::mutex > scoped_lock
Definition: thread.h:49
Implementation details to support the signal processing abstractionThis class contains implementation...
Definition: block_detail.h:44
gr::thread::condition_variable input_cond
Definition: tpb_detail.h:40
void clear_changed()
Called by us.
Definition: tpb_detail.h:69
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
bool input_changed
Definition: tpb_detail.h:39
gr::thread::mutex mutex
Definition: tpb_detail.h:38
used by thread-per-block scheduler
Definition: tpb_detail.h:37
void notify_msg()
Called by pmt msg posters.
Definition: tpb_detail.h:59
tpb_detail()
Definition: tpb_detail.h:45
boost::mutex mutex
Definition: thread.h:48
gr::thread::condition_variable output_cond
Definition: tpb_detail.h:42
boost::condition_variable condition_variable
Definition: thread.h:50
bool output_changed
Definition: tpb_detail.h:41