3 * Copyright 2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
21 #ifndef INCLUDED_GR_TPB_DETAIL_H
22 #define INCLUDED_GR_TPB_DETAIL_H
24 #include <boost/thread.hpp>
26 class gr_block_detail;
29 * \brief used by thread-per-block scheduler
31 struct gr_tpb_detail {
32 typedef boost::unique_lock<boost::mutex> scoped_lock;
34 boost::mutex mutex; //< protects all vars
36 boost::condition_variable input_cond;
38 boost::condition_variable output_cond;
41 : input_changed(false), output_changed(false) {}
44 //! Called by us to tell all our upstream blocks that their output may have changed.
45 void notify_upstream(gr_block_detail *d);
47 //! Called by us to tell all our downstream blocks that their input may have changed.
48 void notify_downstream(gr_block_detail *d);
50 //! Called by us to notify both upstream and downstream
51 void notify_neighbors(gr_block_detail *d);
56 scoped_lock guard(mutex);
57 input_changed = false;
58 output_changed = false;
63 //! Used by notify_downstream
64 void set_input_changed()
66 scoped_lock guard(mutex);
68 input_cond.notify_one();
71 //! Used by notify_upstream
72 void set_output_changed()
74 scoped_lock guard(mutex);
75 output_changed = true;
76 output_cond.notify_one();
81 #endif /* INCLUDED_GR_TPB_DETAIL_H */