[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11502 - in gnuradio/branches/features/msg-passing: gn
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r11502 - in gnuradio/branches/features/msg-passing: gnuradio-core/src/lib/runtime gruel/src/include/gruel gruel/src/lib/msg |
Date: |
Sun, 26 Jul 2009 18:40:23 -0600 (MDT) |
Author: jcorgan
Date: 2009-07-26 18:40:23 -0600 (Sun, 26 Jul 2009)
New Revision: 11502
Modified:
gnuradio/branches/features/msg-passing/gnuradio-core/src/lib/runtime/gr_basic_block.cc
gnuradio/branches/features/msg-passing/gnuradio-core/src/lib/runtime/gr_basic_block.h
gnuradio/branches/features/msg-passing/gruel/src/include/gruel/msg_accepter_msgq.h
gnuradio/branches/features/msg-passing/gruel/src/lib/msg/msg_accepter_msgq.cc
Log:
Added msg_accepter_msgq as mixin for gr_basic_block.
This gives every block and hierarchical block in GNU Radio
a (pmt) message queue and overridable handle_msg() function.
The blocks are sent messages by invoking their call() operator.
The thread-per-block scheduler will be responsible for dequeuing
the messages and calling handle_msg() appropriately.
Renamed queue member name and getter in libgruel to avoid name
clashes with existing GR blocks. Eventually those blocks will
come to use the new message passing API, and the clash will go
away.
Branch passes check.
Modified:
gnuradio/branches/features/msg-passing/gnuradio-core/src/lib/runtime/gr_basic_block.cc
===================================================================
---
gnuradio/branches/features/msg-passing/gnuradio-core/src/lib/runtime/gr_basic_block.cc
2009-07-26 23:34:05 UTC (rev 11501)
+++
gnuradio/branches/features/msg-passing/gnuradio-core/src/lib/runtime/gr_basic_block.cc
2009-07-27 00:40:23 UTC (rev 11502)
@@ -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::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++),
Modified:
gnuradio/branches/features/msg-passing/gnuradio-core/src/lib/runtime/gr_basic_block.h
===================================================================
---
gnuradio/branches/features/msg-passing/gnuradio-core/src/lib/runtime/gr_basic_block.h
2009-07-26 23:34:05 UTC (rev 11501)
+++
gnuradio/branches/features/msg-passing/gnuradio-core/src/lib/runtime/gr_basic_block.h
2009-07-27 00:40:23 UTC (rev 11502)
@@ -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 @@
* 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)
Modified:
gnuradio/branches/features/msg-passing/gruel/src/include/gruel/msg_accepter_msgq.h
===================================================================
---
gnuradio/branches/features/msg-passing/gruel/src/include/gruel/msg_accepter_msgq.h
2009-07-26 23:34:05 UTC (rev 11501)
+++
gnuradio/branches/features/msg-passing/gruel/src/include/gruel/msg_accepter_msgq.h
2009-07-27 00:40:23 UTC (rev 11502)
@@ -32,7 +32,7 @@
*/
class msg_accepter_msgq : public msg_accepter
{
- msg_queue_sptr d_msgq;
+ msg_queue_sptr d_msg_queue;
public:
msg_accepter_msgq(msg_queue_sptr msgq);
@@ -40,7 +40,7 @@
void operator()(pmt::pmt_t msg);
- msg_queue_sptr msgq() const { return d_msgq; }
+ msg_queue_sptr msg_queue() const { return d_msg_queue; }
};
} /* namespace gruel */
Modified:
gnuradio/branches/features/msg-passing/gruel/src/lib/msg/msg_accepter_msgq.cc
===================================================================
---
gnuradio/branches/features/msg-passing/gruel/src/lib/msg/msg_accepter_msgq.cc
2009-07-26 23:34:05 UTC (rev 11501)
+++
gnuradio/branches/features/msg-passing/gruel/src/lib/msg/msg_accepter_msgq.cc
2009-07-27 00:40:23 UTC (rev 11502)
@@ -30,7 +30,7 @@
namespace gruel {
msg_accepter_msgq::msg_accepter_msgq(msg_queue_sptr msgq)
- : d_msgq(msgq)
+ : d_msg_queue(msgq)
{
}
@@ -42,7 +42,7 @@
void
msg_accepter_msgq::operator()(pmt_t msg)
{
- d_msgq->insert_tail(msg);
+ d_msg_queue->insert_tail(msg);
}
} /* namespace gruel */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11502 - in gnuradio/branches/features/msg-passing: gnuradio-core/src/lib/runtime gruel/src/include/gruel gruel/src/lib/msg,
jcorgan <=