diff options
author | jcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5> | 2009-07-25 17:39:00 +0000 |
---|---|---|
committer | jcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5> | 2009-07-25 17:39:00 +0000 |
commit | 4b4da4852482546157abbf8589f2a85bac6c3509 (patch) | |
tree | 02ffd52e5138661205d4c771c11fb759a079650c /gnuradio-core/src | |
parent | 1ea9f1bb015a543a60fb5f89c49c8093d7e069d6 (diff) |
Merge r11462:11485 from jcorgan/omni into trunk.
Removes dependency on omnithreads from gnuradio-core.
Trunk passes distcheck.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11486 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src')
19 files changed, 96 insertions, 102 deletions
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc index 29ac0dbb1d..5ddeeb4d56 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2007 Free Software Foundation, Inc. + * Copyright 2004,2006,2007,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,6 +31,7 @@ #include <fcntl.h> #include <stdexcept> #include <stdio.h> +#include <gruel/thread.h> // win32 (mingw/msvc) specific #ifdef HAVE_IO_H @@ -68,7 +69,7 @@ gr_file_sink_base::~gr_file_sink_base () bool gr_file_sink_base::open(const char *filename) { - omni_mutex_lock l(d_mutex); // hold mutex for duration of this function + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function // we use the open system call to get access to the O_LARGEFILE flag. int fd; @@ -96,7 +97,7 @@ gr_file_sink_base::open(const char *filename) void gr_file_sink_base::close() { - omni_mutex_lock l(d_mutex); // hold mutex for duration of this function + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function if (d_new_fp){ fclose(d_new_fp); @@ -109,7 +110,7 @@ void gr_file_sink_base::do_update() { if (d_updated){ - omni_mutex_lock l(d_mutex); // hold mutex for duration of this block + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block if (d_fp) fclose(d_fp); d_fp = d_new_fp; // install new file pointer diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h index f36f5ac978..0c028d7fd3 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.h +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2007 Free Software Foundation, Inc. + * Copyright 2004,2007,2008 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,7 +23,7 @@ #ifndef INCLUDED_GR_FILE_SINK_BASE_H #define INCLUDED_GR_FILE_SINK_BASE_H -#include <gnuradio/omnithread.h> +#include <boost/thread.hpp> #include <cstdio> /*! @@ -36,7 +36,7 @@ class gr_file_sink_base FILE *d_new_fp; // new FILE pointer bool d_updated; // is there a new FILE pointer? bool d_is_binary; - omni_mutex d_mutex; + boost::mutex d_mutex; protected: gr_file_sink_base(const char *filename, bool is_binary); diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.cc b/gnuradio-core/src/lib/io/gr_udp_sink.cc index 215eaf8d55..d37adfb8a8 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.cc +++ b/gnuradio-core/src/lib/io/gr_udp_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -36,6 +36,8 @@ typedef void* optval_t; typedef char* optval_t; #endif +#include <gruel/thread.h> + #define SNK_VERBOSE 0 gr_udp_sink::gr_udp_sink (size_t itemsize, @@ -110,7 +112,7 @@ gr_udp_sink::~gr_udp_sink () bool gr_udp_sink::open() { - omni_mutex_lock l(d_mutex); // hold mutex for duration of this function + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function // create socket if((d_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { @@ -153,7 +155,7 @@ gr_udp_sink::open() void gr_udp_sink::close() { - omni_mutex_lock l(d_mutex); // hold mutex for duration of this function + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function if (d_socket){ shutdown(d_socket, SHUT_RDWR); diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.h b/gnuradio-core/src/lib/io/gr_udp_sink.h index 13b2befc9e..f22b92dd03 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.h +++ b/gnuradio-core/src/lib/io/gr_udp_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,7 +24,7 @@ #define INCLUDED_GR_UDP_SINK_H #include <gr_sync_block.h> -#include <gnuradio/omnithread.h> +#include <boost/thread.hpp> #if defined(HAVE_SOCKET) #include <sys/socket.h> #include <arpa/inet.h> @@ -36,6 +36,8 @@ #include <netinet/in.h> #endif +#include <gruel/thread.h> + class gr_udp_sink; typedef boost::shared_ptr<gr_udp_sink> gr_udp_sink_sptr; @@ -69,7 +71,7 @@ class gr_udp_sink : public gr_sync_block private: size_t d_itemsize; bool d_updated; - omni_mutex d_mutex; + gruel::mutex d_mutex; int d_payload_size; // maximum transmission unit (packet length) int d_socket; // handle to socket diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc index 9b6ee6e7d8..d76d0ee32f 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.cc +++ b/gnuradio-core/src/lib/io/gr_udp_source.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -90,7 +90,7 @@ gr_udp_source::~gr_udp_source () bool gr_udp_source::open() { - omni_mutex_lock l(d_mutex); // hold mutex for duration of this function + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function // create socket d_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if(d_socket == -1) { @@ -137,7 +137,7 @@ gr_udp_source::open() void gr_udp_source::close() { - omni_mutex_lock l(d_mutex); // hold mutex for duration of this function + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function if (d_socket){ shutdown(d_socket, SHUT_RDWR); diff --git a/gnuradio-core/src/lib/io/gr_udp_source.h b/gnuradio-core/src/lib/io/gr_udp_source.h index afc41a45a2..61d719e4da 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.h +++ b/gnuradio-core/src/lib/io/gr_udp_source.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,7 +24,6 @@ #define INCLUDED_GR_UDP_SOURCE_H #include <gr_sync_block.h> -#include <gnuradio/omnithread.h> #if defined(HAVE_SOCKET) #include <sys/socket.h> #include <arpa/inet.h> @@ -36,6 +35,8 @@ #include <netinet/in.h> #endif +#include <gruel/thread.h> + class gr_udp_source; typedef boost::shared_ptr<gr_udp_source> gr_udp_source_sptr; @@ -63,7 +64,7 @@ class gr_udp_source : public gr_sync_block private: size_t d_itemsize; bool d_updated; - omni_mutex d_mutex; + gruel::mutex d_mutex; int d_payload_size; // maximum transmission unit (packet length) int d_socket; // handle to socket diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc index f06c33d5cd..72e4ef51e0 100644 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc +++ b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2007,2008 Free Software Foundation, Inc. + * Copyright 2004,2006,2007,2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,6 +32,7 @@ #include <cstring> #include <cmath> #include <fcntl.h> +#include <gruel/thread.h> // win32 (mingw/msvc) specific #ifdef HAVE_IO_H @@ -103,7 +104,7 @@ gr_wavfile_sink::gr_wavfile_sink(const char *filename, bool gr_wavfile_sink::open(const char* filename) { - omni_mutex_lock l(d_mutex); + gruel::scoped_lock guard(d_mutex); // we use the open system call to get access to the O_LARGEFILE flag. int fd; @@ -141,7 +142,7 @@ gr_wavfile_sink::open(const char* filename) void gr_wavfile_sink::close() { - omni_mutex_lock l(d_mutex); + gruel::scoped_lock guard(d_mutex); if (!d_fp) return; @@ -230,7 +231,7 @@ gr_wavfile_sink::convert_to_short(float sample) void gr_wavfile_sink::set_bits_per_sample(int bits_per_sample) { - omni_mutex_lock l(d_mutex); + gruel::scoped_lock guard(d_mutex); if (bits_per_sample == 8 || bits_per_sample == 16) { d_bytes_per_sample_new = bits_per_sample / 8; } @@ -240,7 +241,7 @@ gr_wavfile_sink::set_bits_per_sample(int bits_per_sample) void gr_wavfile_sink::set_sample_rate(unsigned int sample_rate) { - omni_mutex_lock l(d_mutex); + gruel::scoped_lock guard(d_mutex); d_sample_rate = sample_rate; } @@ -252,7 +253,7 @@ gr_wavfile_sink::do_update() return; } - omni_mutex_lock l(d_mutex); // hold mutex for duration of this block + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block if (d_fp) { close_wav(); } diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.h b/gnuradio-core/src/lib/io/gr_wavfile_sink.h index fd1d0bf6f1..a1d6ed5271 100644 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.h +++ b/gnuradio-core/src/lib/io/gr_wavfile_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,7 +25,7 @@ #include <gr_sync_block.h> #include <gr_file_sink_base.h> -#include <gnuradio/omnithread.h> +#include <boost/thread.hpp> class gr_wavfile_sink; typedef boost::shared_ptr<gr_wavfile_sink> gr_wavfile_sink_sptr; @@ -76,7 +76,7 @@ private: FILE *d_fp; FILE *d_new_fp; bool d_updated; - omni_mutex d_mutex; + boost::mutex d_mutex; /*! * \brief Convert a sample value within [-1;+1] to a corresponding diff --git a/gnuradio-core/src/lib/io/gri_logger.cc b/gnuradio-core/src/lib/io/gri_logger.cc index c085a93c8d..473a7c5edc 100644 --- a/gnuradio-core/src/lib/io/gri_logger.cc +++ b/gnuradio-core/src/lib/io/gri_logger.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,6 +24,8 @@ #include <config.h> #endif +#if 0 // This needs reimplementation with boost threads and synchronization + #include <gri_logger.h> #include <stdio.h> #include <stdarg.h> @@ -172,3 +174,5 @@ gri_logger::printf(const char *format, ...) if (n > -1 && n < (ssize_t) sizeof(buf)) write(buf, n); } + +#endif diff --git a/gnuradio-core/src/lib/io/gri_logger.h b/gnuradio-core/src/lib/io/gri_logger.h index e5caf7d06a..0a1414540f 100644 --- a/gnuradio-core/src/lib/io/gri_logger.h +++ b/gnuradio-core/src/lib/io/gri_logger.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,6 +22,8 @@ #ifndef INCLUDED_GRI_LOGGER_H #define INCLUDED_GRI_LOGGER_H +#if 0 // This needs reimplementation with boost threads and synchronization + #include <stddef.h> #include <gnuradio/omnithread.h> #include <gr_buffer.h> @@ -52,4 +54,6 @@ public: void printf(const char *format, ...); }; +#endif + #endif /* INCLUDED_GRI_LOGGER_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index fd3a916d4a..e8d30b9632 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -68,7 +68,7 @@ min_available_space (gr_block_detail *d, int output_multiple) int min_space = std::numeric_limits<int>::max(); for (int i = 0; i < d->noutputs (); i++){ - gr_buffer::scoped_lock guard(*d->output(i)->mutex()); + gruel::scoped_lock guard(*d->output(i)->mutex()); #if 0 int n = round_down(d->output(i)->space_available(), output_multiple); #else @@ -163,7 +163,7 @@ gr_block_executor::run_one_iteration() /* * Acquire the mutex and grab local copies of items_available and done. */ - gr_buffer::scoped_lock guard(*d->input(i)->mutex()); + gruel::scoped_lock guard(*d->input(i)->mutex()); d_ninput_items[i] = d->input(i)->items_available(); d_input_done[i] = d->input(i)->done(); } @@ -205,7 +205,7 @@ gr_block_executor::run_one_iteration() /* * Acquire the mutex and grab local copies of items_available and done. */ - gr_buffer::scoped_lock guard(*d->input(i)->mutex()); + gruel::scoped_lock guard(*d->input(i)->mutex()); d_ninput_items[i] = d->input(i)->items_available (); d_input_done[i] = d->input(i)->done(); } diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc index 31a471ea75..db2db5d6d7 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.cc +++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -175,14 +175,14 @@ gr_buffer::write_pointer () void gr_buffer::update_write_pointer (int nitems) { - scoped_lock guard(*mutex()); + gruel::scoped_lock guard(*mutex()); d_write_index = index_add (d_write_index, nitems); } void gr_buffer::set_done (bool done) { - scoped_lock guard(*mutex()); + gruel::scoped_lock guard(*mutex()); d_done = done; } @@ -251,7 +251,7 @@ gr_buffer_reader::read_pointer () void gr_buffer_reader::update_read_pointer (int nitems) { - scoped_lock guard(*mutex()); + gruel::scoped_lock guard(*mutex()); d_read_index = d_buffer->index_add (d_read_index, nitems); } diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h index cb593eea34..207bfe7c58 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.h +++ b/gnuradio-core/src/lib/runtime/gr_buffer.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,7 +25,7 @@ #include <gr_runtime_types.h> #include <boost/weak_ptr.hpp> -#include <boost/thread.hpp> +#include <gruel/thread.h> class gr_vmcircbuf; @@ -50,8 +50,6 @@ gr_buffer_sptr gr_make_buffer (int nitems, size_t sizeof_item, gr_block_sptr lin class gr_buffer { public: - typedef boost::unique_lock<boost::mutex> scoped_lock; - virtual ~gr_buffer (); /*! @@ -88,7 +86,7 @@ class gr_buffer { size_t nreaders() const { return d_readers.size(); } gr_buffer_reader* reader(size_t index) { return d_readers[index]; } - boost::mutex *mutex() { return &d_mutex; } + gruel::mutex *mutex() { return &d_mutex; } // ------------------------------------------------------------------------- @@ -110,7 +108,7 @@ class gr_buffer { // // The mutex protects d_write_index, d_done and the d_read_index's in the buffer readers. // - boost::mutex d_mutex; + gruel::mutex d_mutex; unsigned int d_write_index; // in items [0,d_bufsize) bool d_done; @@ -185,8 +183,6 @@ long gr_buffer_ncurrently_allocated (); class gr_buffer_reader { public: - typedef gr_buffer::scoped_lock scoped_lock; - ~gr_buffer_reader (); /*! @@ -221,7 +217,7 @@ class gr_buffer_reader { void set_done (bool done) { d_buffer->set_done (done); } bool done () const { return d_buffer->done (); } - boost::mutex *mutex() { return d_buffer->mutex(); } + gruel::mutex *mutex() { return d_buffer->mutex(); } /*! diff --git a/gnuradio-core/src/lib/runtime/gr_msg_queue.cc b/gnuradio-core/src/lib/runtime/gr_msg_queue.cc index 922eeda03c..3097acc9ee 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_queue.cc +++ b/gnuradio-core/src/lib/runtime/gr_msg_queue.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -26,16 +26,14 @@ #include <gr_msg_queue.h> #include <stdexcept> - gr_msg_queue_sptr gr_make_msg_queue(unsigned int limit) { return gr_msg_queue_sptr (new gr_msg_queue(limit)); } - gr_msg_queue::gr_msg_queue(unsigned int limit) - : d_not_empty(&d_mutex), d_not_full(&d_mutex), + : d_not_empty(), d_not_full(), /*d_head(0), d_tail(0),*/ d_count(0), d_limit(limit) { } @@ -51,10 +49,10 @@ gr_msg_queue::insert_tail(gr_message_sptr msg) if (msg->d_next) throw std::invalid_argument("gr_msg_queue::insert_tail: msg already in queue"); - omni_mutex_lock l(d_mutex); + gruel::scoped_lock guard(d_mutex); while (full_p()) - d_not_full.wait(); + d_not_full.wait(guard); if (d_tail == 0){ d_tail = d_head = msg; @@ -68,17 +66,17 @@ gr_msg_queue::insert_tail(gr_message_sptr msg) msg->d_next.reset(); } d_count++; - d_not_empty.signal(); + d_not_empty.notify_one(); } gr_message_sptr gr_msg_queue::delete_head() { - omni_mutex_lock l(d_mutex); - gr_message_sptr m; + gruel::scoped_lock guard(d_mutex); + gr_message_sptr m; while ((m = d_head) == 0) - d_not_empty.wait(); + d_not_empty.wait(guard); d_head = m->d_next; if (d_head == 0){ @@ -89,15 +87,15 @@ gr_msg_queue::delete_head() d_count--; // m->d_next = 0; m->d_next.reset(); - d_not_full.signal(); + d_not_full.notify_one(); return m; } gr_message_sptr gr_msg_queue::delete_head_nowait() { - omni_mutex_lock l(d_mutex); - gr_message_sptr m; + gruel::scoped_lock guard(d_mutex); + gr_message_sptr m; if ((m = d_head) == 0){ //return 0; @@ -113,7 +111,7 @@ gr_msg_queue::delete_head_nowait() d_count--; //m->d_next = 0; m->d_next.reset(); - d_not_full.signal(); + d_not_full.notify_one(); return m; } diff --git a/gnuradio-core/src/lib/runtime/gr_msg_queue.h b/gnuradio-core/src/lib/runtime/gr_msg_queue.h index f965887e16..477b1ddf1b 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_queue.h +++ b/gnuradio-core/src/lib/runtime/gr_msg_queue.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,7 +23,7 @@ #define INCLUDED_GR_MSG_QUEUE_H #include <gr_msg_handler.h> -#include <gnuradio/omnithread.h> +#include <gruel/thread.h> class gr_msg_queue; typedef boost::shared_ptr<gr_msg_queue> gr_msg_queue_sptr; @@ -35,13 +35,14 @@ gr_msg_queue_sptr gr_make_msg_queue(unsigned int limit=0); * \ingroup misc */ class gr_msg_queue : public gr_msg_handler { - omni_mutex d_mutex; - omni_condition d_not_empty; - omni_condition d_not_full; - gr_message_sptr d_head; - gr_message_sptr d_tail; - unsigned int d_count; // # of messages in queue. - unsigned int d_limit; // max # of messages in queue. 0 -> unbounded + + gruel::mutex d_mutex; + gruel::condition_variable d_not_empty; + gruel::condition_variable d_not_full; + gr_message_sptr d_head; + gr_message_sptr d_tail; + unsigned int d_count; // # of messages in queue. + unsigned int d_limit; // max # of messages in queue. 0 -> unbounded public: gr_msg_queue(unsigned int limit); diff --git a/gnuradio-core/src/lib/runtime/gr_msg_queue.i b/gnuradio-core/src/lib/runtime/gr_msg_queue.i index 254a7a940c..9ca92b6ec8 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_queue.i +++ b/gnuradio-core/src/lib/runtime/gr_msg_queue.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,12 +32,6 @@ gr_msg_queue_sptr gr_make_msg_queue(unsigned limit=0); */ %ignore gr_msg_queue; class gr_msg_queue : public gr_msg_handler { - omni_mutex d_mutex; - omni_condition d_cond; - gr_message_sptr d_head; - gr_message_sptr d_tail; - int d_count; - public: gr_msg_queue(unsigned int limit); ~gr_msg_queue(); diff --git a/gnuradio-core/src/lib/runtime/gr_sptr_magic.cc b/gnuradio-core/src/lib/runtime/gr_sptr_magic.cc index 3295f849e4..96ffae85fe 100644 --- a/gnuradio-core/src/lib/runtime/gr_sptr_magic.cc +++ b/gnuradio-core/src/lib/runtime/gr_sptr_magic.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,19 +27,11 @@ #include <stdexcept> -#if 0 - #include <boost/thread.hpp> - typedef boost::mutex mutex; - typedef boost::mutex::scoped_lock scoped_lock; -#else - #include <gnuradio/omnithread.h> - typedef omni_mutex mutex; - typedef omni_mutex_lock scoped_lock; -#endif +#include <gruel/thread.h> namespace gnuradio { - static mutex s_mutex; + static gruel::mutex s_mutex; typedef std::map<gr_basic_block*, gr_basic_block_sptr> sptr_map; static sptr_map s_map; @@ -47,7 +39,7 @@ namespace gnuradio { detail::sptr_magic::create_and_stash_initial_sptr(gr_hier_block2 *p) { gr_basic_block_sptr sptr(p); - scoped_lock l(); + gruel::scoped_lock guard(); s_map.insert(sptr_map::value_type(static_cast<gr_basic_block *>(p), sptr)); } @@ -68,7 +60,7 @@ namespace gnuradio { * p is a subclass of gr_hier_block2, thus we've already created the shared pointer * and stashed it away. Fish it out and return it. */ - scoped_lock l(); + gruel::scoped_lock guard(); sptr_map::iterator pos = s_map.find(static_cast<gr_basic_block *>(p)); if (pos == s_map.end()) throw std::invalid_argument("gr_sptr_magic: invalid pointer!"); @@ -78,4 +70,3 @@ namespace gnuradio { return sptr; } }; - diff --git a/gnuradio-core/src/lib/runtime/gr_tpb_detail.h b/gnuradio-core/src/lib/runtime/gr_tpb_detail.h index 9566312dc8..ab955240b3 100644 --- a/gnuradio-core/src/lib/runtime/gr_tpb_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_tpb_detail.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,7 +21,7 @@ #ifndef INCLUDED_GR_TPB_DETAIL_H #define INCLUDED_GR_TPB_DETAIL_H -#include <boost/thread.hpp> +#include <gruel/thread.h> class gr_block_detail; @@ -29,13 +29,12 @@ class gr_block_detail; * \brief used by thread-per-block scheduler */ struct gr_tpb_detail { - typedef boost::unique_lock<boost::mutex> scoped_lock; - boost::mutex mutex; //< protects all vars + gruel::mutex mutex; //< protects all vars bool input_changed; - boost::condition_variable input_cond; + gruel::condition_variable input_cond; bool output_changed; - boost::condition_variable output_cond; + gruel::condition_variable output_cond; gr_tpb_detail() : input_changed(false), output_changed(false) {} @@ -53,7 +52,7 @@ struct gr_tpb_detail { //! Called by us void clear_changed() { - scoped_lock guard(mutex); + gruel::scoped_lock guard(mutex); input_changed = false; output_changed = false; } @@ -63,7 +62,7 @@ private: //! Used by notify_downstream void set_input_changed() { - scoped_lock guard(mutex); + gruel::scoped_lock guard(mutex); input_changed = true; input_cond.notify_one(); } @@ -71,7 +70,7 @@ private: //! Used by notify_upstream void set_output_changed() { - scoped_lock guard(mutex); + gruel::scoped_lock guard(mutex); output_changed = true; output_cond.notify_one(); } diff --git a/gnuradio-core/src/lib/runtime/gr_tpb_thread_body.cc b/gnuradio-core/src/lib/runtime/gr_tpb_thread_body.cc index e3abf6d844..458b16d64c 100644 --- a/gnuradio-core/src/lib/runtime/gr_tpb_thread_body.cc +++ b/gnuradio-core/src/lib/runtime/gr_tpb_thread_body.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -54,7 +54,7 @@ gr_tpb_thread_body::gr_tpb_thread_body(gr_block_sptr block) case gr_block_executor::BLKD_IN: // Wait for input. { - gr_tpb_detail::scoped_lock guard(d->d_tpb.mutex); + gruel::scoped_lock guard(d->d_tpb.mutex); while(!d->d_tpb.input_changed) d->d_tpb.input_cond.wait(guard); } @@ -62,7 +62,7 @@ gr_tpb_thread_body::gr_tpb_thread_body(gr_block_sptr block) case gr_block_executor::BLKD_OUT: // Wait for output buffer space. { - gr_tpb_detail::scoped_lock guard(d->d_tpb.mutex); + gruel::scoped_lock guard(d->d_tpb.mutex); while(!d->d_tpb.output_changed) d->d_tpb.output_cond.wait(guard); } |