summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/runtime
diff options
context:
space:
mode:
authorjcorgan2009-08-01 14:56:28 +0000
committerjcorgan2009-08-01 14:56:28 +0000
commit3556ef4080be8b0fe569d28cae6568b761edbd7b (patch)
tree6f08b796f8a1f5a561dce6a8b36f742623812ea7 /gnuradio-core/src/lib/runtime
parent482c0505920258680ba1105e272efcc95cbdb16d (diff)
downloadgnuradio-3556ef4080be8b0fe569d28cae6568b761edbd7b.tar.gz
gnuradio-3556ef4080be8b0fe569d28cae6568b761edbd7b.tar.bz2
gnuradio-3556ef4080be8b0fe569d28cae6568b761edbd7b.zip
Merged r11500:11506 from features/msg-passing into trunk. Work-in-progress, passes distcheck.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11524 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/runtime')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_basic_block.cc5
-rw-r--r--gnuradio-core/src/lib/runtime/gr_basic_block.h20
2 files changed, 20 insertions, 5 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.cc b/gnuradio-core/src/lib/runtime/gr_basic_block.cc
index e94e089e2..71ccc0245 100644
--- a/gnuradio-core/src/lib/runtime/gr_basic_block.cc
+++ b/gnuradio-core/src/lib/runtime/gr_basic_block.cc
@@ -27,6 +27,8 @@
#include <gr_basic_block.h>
#include <stdexcept>
+using namespace pmt;
+
static long s_next_id = 0;
static long s_ncurrently_allocated = 0;
@@ -39,7 +41,8 @@ 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)
- : d_name(name),
+ : gruel::msg_accepter_msgq(gruel::make_msg_queue(0)),
+ d_name(name),
d_input_signature(input_signature),
d_output_signature(output_signature),
d_unique_id(s_next_id++),
diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h
index faaba1c83..27ec0fd89 100644
--- a/gnuradio-core/src/lib/runtime/gr_basic_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2008 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,20 +26,21 @@
#include <gr_runtime_types.h>
#include <gr_sptr_magic.h>
#include <boost/enable_shared_from_this.hpp>
+#include <gruel/msg_accepter_msgq.h>
#include <string>
/*!
* \brief The abstract base class for all signal processing blocks.
* \ingroup internal
*
- * Basic blocks are the bare abstraction of an entity that has a name
- * and a set of inputs and outputs. These are never instantiated
+ * Basic blocks are the bare abstraction of an entity that has a name,
+ * a set of inputs and outputs, and a message queue. These are never instantiated
* directly; rather, this is the abstract parent class of both gr_hier_block,
* which is a recursive container, and gr_block, which implements actual
* signal processing functions.
*/
-class gr_basic_block : public boost::enable_shared_from_this<gr_basic_block>
+class gr_basic_block : gruel::msg_accepter_msgq, public boost::enable_shared_from_this<gr_basic_block>
{
protected:
friend class gr_flowgraph;
@@ -96,6 +97,17 @@ public:
* and output gr_io_signatures.
*/
virtual bool check_topology(int ninputs, int noutputs) { return true; }
+
+ /*!
+ * \brief Block message handler.
+ *
+ * \param msg Arbitrary message encapsulated as pmt::pmt_t
+ *
+ * This function is called by the runtime system whenever there are
+ * messages in its queue. Blocks should override this to receive
+ * messages; the default behavior is to drop them on the floor.
+ */
+ virtual void handle_msg(pmt::pmt_t msg) { };
};
inline bool operator<(gr_basic_block_sptr lhs, gr_basic_block_sptr rhs)