3 * Copyright 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
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.
27 #include <gruel/msg_queue.h>
35 make_msg_queue(unsigned int limit)
37 return msg_queue_sptr(new msg_queue(limit));
40 msg_queue::msg_queue(unsigned int limit)
45 msg_queue::~msg_queue()
51 msg_queue::insert_tail(pmt_t msg)
53 gruel::scoped_lock guard(d_mutex);
56 d_not_full.wait(guard);
58 d_msgs.push_back(msg);
59 d_not_empty.notify_one();
63 msg_queue::delete_head()
65 gruel::scoped_lock guard(d_mutex);
68 d_not_empty.wait(guard);
70 pmt_t m(d_msgs.front());
73 if (d_limit > 0) // Unlimited length queues never block on write
74 d_not_full.notify_one();
80 msg_queue::delete_head_nowait()
82 gruel::scoped_lock guard(d_mutex);
87 pmt_t m(d_msgs.front());
90 if (d_limit > 0) // Unlimited length queues never block on write
91 d_not_full.notify_one();
99 while (delete_head_nowait() != pmt_t())
103 } /* namespace gruel */