From: Johnathan Corgan Date: Sat, 1 Aug 2009 16:43:02 +0000 (-0700) Subject: Added gr_msg_accepter class. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=f67c4ff12f19490d2aeab7ff0fbe0484195037f0;p=debian%2Fgnuradio Added gr_msg_accepter class. gr_msg_accepter derives from gruel::msg_accepter_msgq and will implement in its post() a notification of the destination block thread that a message is pending. Passes distcheck. --- diff --git a/gnuradio-core/src/lib/runtime/Makefile.am b/gnuradio-core/src/lib/runtime/Makefile.am index 14ab464a..b0e80427 100644 --- a/gnuradio-core/src/lib/runtime/Makefile.am +++ b/gnuradio-core/src/lib/runtime/Makefile.am @@ -44,6 +44,7 @@ libruntime_la_SOURCES = \ gr_io_signature.cc \ gr_local_sighandler.cc \ gr_message.cc \ + gr_msg_accepter.cc \ gr_msg_handler.cc \ gr_msg_queue.cc \ gr_pagesize.cc \ @@ -96,6 +97,7 @@ grinclude_HEADERS = \ gr_io_signature.h \ gr_local_sighandler.h \ gr_message.h \ + gr_msg_accepter.h \ gr_msg_handler.h \ gr_msg_queue.h \ gr_pagesize.h \ diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.cc b/gnuradio-core/src/lib/runtime/gr_basic_block.cc index 71ccc024..8efa8267 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.cc @@ -41,7 +41,7 @@ gr_basic_block_ncurrently_allocated() gr_basic_block::gr_basic_block(const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature) - : gruel::msg_accepter_msgq(gruel::make_msg_queue(0)), + : gr_msg_accepter(gruel::make_msg_queue(0)), // Non-blocking insert d_name(name), d_input_signature(input_signature), d_output_signature(output_signature), diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h index 27ec0fd8..5d5b8cbc 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.h +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include /*! @@ -40,7 +40,7 @@ * signal processing functions. */ -class gr_basic_block : gruel::msg_accepter_msgq, public boost::enable_shared_from_this +class gr_basic_block : gr_msg_accepter, public boost::enable_shared_from_this { protected: friend class gr_flowgraph; diff --git a/gnuradio-core/src/lib/runtime/gr_msg_accepter.cc b/gnuradio-core/src/lib/runtime/gr_msg_accepter.cc new file mode 100644 index 00000000..b07f447c --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_msg_accepter.cc @@ -0,0 +1,44 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +using namespace pmt; + +gr_msg_accepter::gr_msg_accepter(gruel::msg_queue_sptr msgq) + : gruel::msg_accepter_msgq(msgq) +{ +} + +gr_msg_accepter::~gr_msg_accepter() +{ + // NOP, required as virtual destructor +} + +void +gr_msg_accepter::post(pmt_t msg) +{ + d_msg_queue->insert_tail(msg); +} diff --git a/gnuradio-core/src/lib/runtime/gr_msg_accepter.h b/gnuradio-core/src/lib/runtime/gr_msg_accepter.h new file mode 100644 index 00000000..8ce8d1d9 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_msg_accepter.h @@ -0,0 +1,40 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef INCLUDED_GR_MSG_ACCEPTER_H +#define INCLUDED_GR_MSG_ACCEPTER_H + +#include + +/*! + * \brief Accepts messages and inserts them into a message queue, then notifies + * subclass gr_basic_block there is a message pending. + */ +class gr_msg_accepter : gruel::msg_accepter_msgq +{ +public: + gr_msg_accepter(gruel::msg_queue_sptr msgq); + ~gr_msg_accepter(); + + void post(pmt::pmt_t msg); +}; + +#endif /* INCLUDED_GR_MSG_ACCEPTER_H */ diff --git a/gruel/src/include/gruel/msg_accepter_msgq.h b/gruel/src/include/gruel/msg_accepter_msgq.h index b14049d5..bf1762e9 100644 --- a/gruel/src/include/gruel/msg_accepter_msgq.h +++ b/gruel/src/include/gruel/msg_accepter_msgq.h @@ -32,13 +32,14 @@ namespace gruel { */ class msg_accepter_msgq : public msg_accepter { + protected: msg_queue_sptr d_msg_queue; public: msg_accepter_msgq(msg_queue_sptr msgq); ~msg_accepter_msgq(); - void post(pmt::pmt_t msg); + virtual void post(pmt::pmt_t msg); msg_queue_sptr msg_queue() const { return d_msg_queue; } };