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.
24 #include <gr_tpb_thread_body.h>
26 #include <boost/thread.hpp>
28 gr_tpb_thread_body::gr_tpb_thread_body(gr_block_sptr block)
31 // std::cerr << "gr_tpb_thread_body: " << block << std::endl;
33 gr_block_detail *d = block->detail().get();
34 gr_block_executor::state s;
37 boost::this_thread::interruption_point();
39 d->d_tpb.clear_changed();
40 s = d_exec.run_one_iteration();
43 case gr_block_executor::READY: // Tell neighbors we made progress.
44 d->d_tpb.notify_neighbors(d);
47 case gr_block_executor::READY_NO_OUTPUT: // Notify upstream only
48 d->d_tpb.notify_upstream(d);
51 case gr_block_executor::DONE: // Game over.
52 d->d_tpb.notify_neighbors(d);
55 case gr_block_executor::BLKD_IN: // Wait for input.
57 gr_tpb_detail::scoped_lock guard(d->d_tpb.mutex);
58 while(!d->d_tpb.input_changed)
59 d->d_tpb.input_cond.wait(guard);
63 case gr_block_executor::BLKD_OUT: // Wait for output buffer space.
65 gr_tpb_detail::scoped_lock guard(d->d_tpb.mutex);
66 while(!d->d_tpb.output_changed)
67 d->d_tpb.output_cond.wait(guard);
77 gr_tpb_thread_body::~gr_tpb_thread_body()