00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2007 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 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_GR_TOP_BLOCK_IMPL_H 00024 #define INCLUDED_GR_TOP_BLOCK_IMPL_H 00025 00026 #include <gr_scheduler_thread.h> 00027 00035 class gr_top_block_impl 00036 { 00037 public: 00038 gr_top_block_impl(gr_top_block *owner); 00039 ~gr_top_block_impl(); 00040 00041 // Create and start scheduler threads 00042 void start(); 00043 00044 // Signal scheduler threads to stop 00045 void stop(); 00046 00047 // Wait for scheduler threads to exit 00048 void wait(); 00049 00050 // Lock the top block to allow reconfiguration 00051 void lock(); 00052 00053 // Unlock the top block at end of reconfiguration 00054 void unlock(); 00055 00056 // Return true if flowgraph is running 00057 bool is_running() const { return d_running; } 00058 00059 private: 00060 00061 bool d_running; 00062 gr_flat_flowgraph_sptr d_ffg; 00063 gr_scheduler_thread_vector_t d_threads; 00064 gr_top_block *d_owner; 00065 int d_lock_count; 00066 omni_mutex d_reconf; 00067 00068 std::vector<gr_basic_block_vector_t> d_graphs; 00069 00070 void start_threads(); 00071 void restart(); 00072 }; 00073 00074 #endif /* INCLUDED_GR_TOP_BLOCK_IMPL_H */