Added gr_msg_accepter class.
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Sat, 1 Aug 2009 16:43:02 +0000 (09:43 -0700)
committerEric Blossom <eb@comsec.com>
Fri, 14 Aug 2009 04:40:08 +0000 (21:40 -0700)
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.

gnuradio-core/src/lib/runtime/Makefile.am
gnuradio-core/src/lib/runtime/gr_basic_block.cc
gnuradio-core/src/lib/runtime/gr_basic_block.h
gnuradio-core/src/lib/runtime/gr_msg_accepter.cc [new file with mode: 0644]
gnuradio-core/src/lib/runtime/gr_msg_accepter.h [new file with mode: 0644]
gruel/src/include/gruel/msg_accepter_msgq.h

index 14ab464ad257835cdc579cf896386b004dd04b1d..b0e80427700c649efbb25bf0e674a96be839e775 100644 (file)
@@ -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                           \
index 71ccc02454c591d21eb31efd094c7da063de5725..8efa8267a4e8e36ec8838d97965614b4587b62a3 100644 (file)
@@ -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),
index 27ec0fd89b1d44ed39745fd835956cb92122b307..5d5b8cbc723448399cdf8a5d6589e3bbc5db4277 100644 (file)
@@ -26,7 +26,7 @@
 #include <gr_runtime_types.h>
 #include <gr_sptr_magic.h>
 #include <boost/enable_shared_from_this.hpp>
-#include <gruel/msg_accepter_msgq.h>
+#include <gr_msg_accepter.h>
 #include <string>
 
 /*!
@@ -40,7 +40,7 @@
  * signal processing functions.
  */
 
-class gr_basic_block : gruel::msg_accepter_msgq, public boost::enable_shared_from_this<gr_basic_block>
+class gr_basic_block : gr_msg_accepter, public boost::enable_shared_from_this<gr_basic_block>
 {
 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 (file)
index 0000000..b07f447
--- /dev/null
@@ -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 <config.h>
+#endif
+
+#include <gr_msg_accepter.h>
+
+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 (file)
index 0000000..8ce8d1d
--- /dev/null
@@ -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 <gruel/msg_accepter_msgq.h>
+
+/*!
+ * \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 */
index b14049d54f8ff134839ec10b3342a29e2676ba98..bf1762e925e5ab2e09f219d5a2b16794f83737f3 100644 (file)
@@ -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; }
   };