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.
25 #include <gr_scheduler_sts.h>
26 #include <gr_single_threaded_scheduler.h>
27 #include <gruel/thread_body_wrapper.h>
31 gr_block_vector_t d_blocks;
35 sts_container(gr_block_vector_t blocks)
40 gr_make_single_threaded_scheduler(d_blocks)->run();
46 gr_scheduler_sts::make(gr_flat_flowgraph_sptr ffg)
48 return gr_scheduler_sptr(new gr_scheduler_sts(ffg));
51 gr_scheduler_sts::gr_scheduler_sts(gr_flat_flowgraph_sptr ffg)
54 // Split the flattened flow graph into discrete partitions, each
55 // of which is topologically sorted.
57 std::vector<gr_basic_block_vector_t> graphs = ffg->partition();
59 // For each partition, create a thread to evaluate it using
60 // an instance of the gr_single_threaded_scheduler
62 for (std::vector<gr_basic_block_vector_t>::iterator p = graphs.begin();
63 p != graphs.end(); p++) {
65 gr_block_vector_t blocks = gr_flat_flowgraph::make_block_vector(*p);
66 d_threads.create_thread(
67 gruel::thread_body_wrapper<sts_container>(sts_container(blocks),
68 "single-threaded-scheduler"));
72 gr_scheduler_sts::~gr_scheduler_sts()
78 gr_scheduler_sts::stop()
80 d_threads.interrupt_all();
84 gr_scheduler_sts::wait()