3 * Copyright 2008,2009 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_tpb_detail.h>
27 #include <gr_block_detail.h>
28 #include <gr_buffer.h>
33 * We assume that no worker threads are ever running when the
34 * graph structure is being manipulated, thus it's safe for us to poke
35 * around in our neighbors w/o holding any locks.
39 gr_tpb_detail::notify_upstream(gr_block_detail *d)
41 // For each of our inputs, tell the guy upstream that we've consumed
42 // some input, and that he most likely has more output buffer space
45 for (size_t i = 0; i < d->d_input.size(); i++){
46 // Can you say, "pointer chasing?"
47 d->d_input[i]->buffer()->link()->detail()->d_tpb.set_output_changed();
52 gr_tpb_detail::notify_downstream(gr_block_detail *d)
54 // For each of our outputs, tell the guys downstream that they have
55 // new input available.
57 for (size_t i = 0; i < d->d_output.size(); i++){
58 gr_buffer_sptr buf = d->d_output[i];
59 for (size_t j = 0, k = buf->nreaders(); j < k; j++)
60 buf->reader(j)->link()->detail()->d_tpb.set_input_changed();
65 gr_tpb_detail::notify_neighbors(gr_block_detail *d)
72 gr_tpb_detail::insert_tail(pmt::pmt_t msg)
74 gruel::scoped_lock guard(mutex);
76 msg_queue.push_back(msg);
78 // wake up thread if BLKD_IN or BLKD_OUT
79 input_cond.notify_one();
80 output_cond.notify_one();
84 gr_tpb_detail::delete_head_nowait()
86 gruel::scoped_lock guard(mutex);
91 pmt_t m(msg_queue.front());
92 msg_queue.pop_front();
98 * Caller must already be holding the mutex
101 gr_tpb_detail::delete_head_nowait_already_holding_mutex()
106 pmt_t m(msg_queue.front());
107 msg_queue.pop_front();