3 * Copyright 2005 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 2, 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
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
26 #include <gr_msg_queue.h>
31 gr_make_msg_queue(unsigned int limit)
33 return gr_msg_queue_sptr (new gr_msg_queue(limit));
37 gr_msg_queue::gr_msg_queue(unsigned int limit)
38 : d_not_empty(&d_mutex), d_not_full(&d_mutex),
39 /*d_head(0), d_tail(0),*/ d_count(0), d_limit(limit)
43 gr_msg_queue::~gr_msg_queue()
49 gr_msg_queue::insert_tail(gr_message_sptr msg)
52 throw std::invalid_argument("gr_msg_queue::insert_tail: msg already in queue");
54 omni_mutex_lock l(d_mutex);
60 d_tail = d_head = msg;
75 gr_msg_queue::delete_head()
77 omni_mutex_lock l(d_mutex);
80 while ((m = d_head) == 0)
97 gr_msg_queue::delete_head_nowait()
99 omni_mutex_lock l(d_mutex);
102 if ((m = d_head) == 0){
104 return gr_message_sptr();
121 gr_msg_queue::flush()
125 while ((m = delete_head_nowait ()) != 0)