3 * Copyright 2008,2010 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.
21 #ifndef INCLUDED_RING_H
22 #define INCLUDED_RING_H
26 #include <boost/shared_ptr.hpp>
27 #include <gruel/thread.h>
32 typedef boost::shared_ptr<ring> ring_sptr;
47 std::vector<ring_desc> d_ring;
50 gruel::condition_variable d_not_empty;
54 if (d_read_ind + 1 >= d_max)
57 d_read_ind = d_read_ind + 1;
62 if (d_write_ind + 1 >= d_max)
65 d_write_ind = d_write_ind + 1;
68 bool empty() const { return d_read_ind == d_write_ind; }
69 bool full() const { return (d_write_ind+1)%d_max == d_read_ind; }
73 ring(unsigned int entries);
75 void wait_for_not_empty();
77 bool enqueue(void *p, size_t len);
78 bool dequeue(void **p, size_t *len);
83 #endif /* INCLUDED_RING_H */