GNU Radio Manual and C++ API Reference  3.7.13.4
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 <deque>
28 #include <pmt/pmt.h>
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:
46  : input_changed(false), output_changed(false) { }
47 
48  //! Called by us to tell all our upstream blocks that their output
49  //! may have changed.
50  void notify_upstream(block_detail *d);
51 
52  //! Called by us to tell all our downstream blocks that their
53  //! input may have changed.
54  void notify_downstream(block_detail *d);
55 
56  //! Called by us to notify both upstream and downstream
57  void notify_neighbors(block_detail *d);
58 
59  //! Called by pmt msg posters
60  void notify_msg() {
61  input_cond.notify_one();
62  output_cond.notify_one();
63  }
64 
65  //! Called by us
67  {
68  gr::thread::scoped_lock guard(mutex);
69  input_changed = false;
70  output_changed = false;
71  }
72 
73  private:
74  //! Used by notify_downstream
75  void set_input_changed()
76  {
77  gr::thread::scoped_lock guard(mutex);
78  input_changed = true;
79  input_cond.notify_one();
80  }
81 
82  //! Used by notify_upstream
83  void set_output_changed()
84  {
85  gr::thread::scoped_lock guard(mutex);
86  output_changed = true;
87  output_cond.notify_one();
88  }
89  };
90 
91 } /* namespace gr */
92 
93 #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:66
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
Include this header to use the message passing features.
Definition: logger.h:695
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:60
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