gr_tpb_detail.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2008 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_GR_TPB_DETAIL_H
00022 #define INCLUDED_GR_TPB_DETAIL_H
00023 
00024 #include <boost/thread.hpp>
00025 
00026 class gr_block_detail;
00027 
00028 /*!
00029  * \brief used by thread-per-block scheduler
00030  */
00031 struct gr_tpb_detail {
00032   typedef boost::unique_lock<boost::mutex>  scoped_lock;
00033 
00034   boost::mutex                  mutex;                  //< protects all vars
00035   bool                          input_changed;
00036   boost::condition_variable     input_cond;
00037   bool                          output_changed;
00038   boost::condition_variable     output_cond;
00039 
00040   gr_tpb_detail()
00041     : input_changed(false), output_changed(false) {}
00042 
00043 
00044   //! Called by us to tell all our upstream blocks that their output may have changed.
00045   void notify_upstream(gr_block_detail *d);
00046 
00047   //! Called by us to tell all our downstream blocks that their input may have changed.
00048   void notify_downstream(gr_block_detail *d);
00049 
00050   //! Called by us to notify both upstream and downstream
00051   void notify_neighbors(gr_block_detail *d);
00052 
00053   //! Called by us
00054   void clear_changed()
00055   {
00056     scoped_lock guard(mutex);
00057     input_changed = false;
00058     output_changed = false;
00059   }
00060 
00061 private:
00062 
00063   //! Used by notify_downstream
00064   void set_input_changed()
00065   {
00066     scoped_lock guard(mutex);
00067     input_changed = true;
00068     input_cond.notify_one();
00069   }
00070 
00071   //! Used by notify_upstream
00072   void set_output_changed()
00073   {
00074     scoped_lock guard(mutex);
00075     output_changed = true;
00076     output_cond.notify_one();
00077   }
00078 
00079 };
00080 
00081 #endif /* INCLUDED_GR_TPB_DETAIL_H */

Generated on Wed Jul 29 06:29:48 2009 for GNU Radio 3.2.2 C++ API by  doxygen 1.5.9