From ab8c921bf73b61c19305bc0bf1fc4d26b110779e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 8 Nov 2010 19:52:50 -0500 Subject: Adding mutex protection around adding and getting tags from buffers. --- gnuradio-core/src/lib/runtime/gr_buffer.cc | 3 +++ gnuradio-core/src/lib/runtime/gr_buffer.h | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'gnuradio-core/src/lib') 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 gr_buffer_reader::get_tags_in_range(uint64_t abs_start, uint64_t abs_end) { + gruel::scoped_lock guard(*mutex()); + std::vector found_items; std::deque::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 d_readers; boost::weak_ptr d_link; // block that writes to this buffer - std::deque 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 d_item_tags; + unsigned index_add (unsigned a, unsigned b) -- cgit