summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorTom Rondeau2010-11-08 19:52:50 -0500
committerTom Rondeau2010-11-08 19:52:50 -0500
commitab8c921bf73b61c19305bc0bf1fc4d26b110779e (patch)
tree7db1191c966c5cf75f4d3c77763bef99b2fd952d /gnuradio-core/src/lib
parent4cb301dec845778e468c73dac5eb04a9dfccb14a (diff)
downloadgnuradio-ab8c921bf73b61c19305bc0bf1fc4d26b110779e.tar.gz
gnuradio-ab8c921bf73b61c19305bc0bf1fc4d26b110779e.tar.bz2
gnuradio-ab8c921bf73b61c19305bc0bf1fc4d26b110779e.zip
Adding mutex protection around adding and getting tags from buffers.
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.cc3
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.h10
2 files changed, 7 insertions, 6 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc
index 862d92b81..1d67470ec 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.cc
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc
@@ -219,6 +219,7 @@ gr_buffer::drop_reader (gr_buffer_reader *reader)
void
gr_buffer::add_item_tag(const pmt::pmt_t &tag)
{
+ gruel::scoped_lock guard(*mutex());
d_item_tags.push_back(tag);
}
@@ -267,6 +268,8 @@ std::vector<pmt::pmt_t>
gr_buffer_reader::get_tags_in_range(uint64_t abs_start,
uint64_t abs_end)
{
+ gruel::scoped_lock guard(*mutex());
+
std::vector<pmt::pmt_t> found_items;
std::deque<pmt::pmt_t>::iterator itr = d_buffer->get_tags_begin();
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h
index 5f11b4581..d6d5564e8 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.h
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.h
@@ -119,18 +119,16 @@ class gr_buffer {
std::vector<gr_buffer_reader *> d_readers;
boost::weak_ptr<gr_block> d_link; // block that writes to this buffer
- std::deque<pmt::pmt_t> d_item_tags;
-
-
//
- // The mutex protects d_write_index, d_abs_write_offset, d_done and the d_read_index's
- // and d_abs_read_offset's in the buffer readers.
+ // The mutex protects d_write_index, d_abs_write_offset, d_done, d_item_tags
+ // and the d_read_index's and d_abs_read_offset's in the buffer readers.
//
gruel::mutex d_mutex;
unsigned int d_write_index; // in items [0,d_bufsize)
uint64_t d_abs_write_offset; // num items written since the start
- //deq tag_tuples
bool d_done;
+ std::deque<pmt::pmt_t> d_item_tags;
+
unsigned
index_add (unsigned a, unsigned b)