summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gnuradio/block.hpp2
-rw-r--r--include/gnuradio/gr_top_block.h26
-rw-r--r--include/gnuradio/top_block.hpp43
-rw-r--r--lib/top_block.cpp14
4 files changed, 51 insertions, 34 deletions
diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp
index 0543161..81984f0 100644
--- a/include/gnuradio/block.hpp
+++ b/include/gnuradio/block.hpp
@@ -78,7 +78,7 @@ struct GRAS_API OutputPortConfig
size_t reserve_items;
/*!
- * Constrain the maximum buffer size that
+ * Constrain the maximum number of items that
* work can be called with for this port.
*
* Default = 0 aka disabled.
diff --git a/include/gnuradio/gr_top_block.h b/include/gnuradio/gr_top_block.h
index eb1a9aa..3a56bf6 100644
--- a/include/gnuradio/gr_top_block.h
+++ b/include/gnuradio/gr_top_block.h
@@ -37,9 +37,29 @@ struct GRAS_API gr_top_block : gnuradio::TopBlock
this->update();
}
- ///////////// TODO //////////////////////
- int max_noutput_items(){return 0;}
- void set_max_noutput_items(int){}
+ void start(const size_t max_items)
+ {
+ this->set_max_noutput_items(max_items);
+ gnuradio::TopBlock::start();
+ }
+
+ void run(const size_t max_items)
+ {
+ this->set_max_noutput_items(max_items);
+ gnuradio::TopBlock::run();
+ }
+
+ int max_noutput_items(void) const
+ {
+ return this->global_config().maximum_output_items;
+ }
+
+ void set_max_noutput_items(int max_items)
+ {
+ gnuradio::GlobalBlockConfig config = this->global_config();
+ config.maximum_output_items = max_items;
+ this->set_global_config(config);
+ }
};
diff --git a/include/gnuradio/top_block.hpp b/include/gnuradio/top_block.hpp
index d755ffc..bab67ee 100644
--- a/include/gnuradio/top_block.hpp
+++ b/include/gnuradio/top_block.hpp
@@ -22,38 +22,37 @@
namespace gnuradio
{
+struct GRAS_API GlobalBlockConfig
+{
+ GlobalBlockConfig(void);
+
+ /*!
+ * Constrain the maximum number of items that
+ * work can be called with for all output ports.
+ *
+ * Default = 0 aka disabled.
+ */
+ size_t maximum_output_items;
+};
+
struct GRAS_API TopBlock : HierBlock
{
TopBlock(void);
TopBlock(const std::string &name);
+ //! Get the global block config settings
+ const GlobalBlockConfig &global_config(void) const;
+
+ //! Set the global block config settings
+ void set_global_config(const GlobalBlockConfig &config);
+
/*!
* Commit changes to the overall flow graph.
* Call this after modifying connections.
- * Update is called automatically by start/stop/run.
- */
- void update(void);
-
- /*!
- * Set the buffer allocation hint.
- * This affects the size of buffers.
+ * Commit is called automatically by start/stop/run.
*/
- void set_buffer_hint(const size_t hint);
-
- //! Combined hint + start
- void start(const size_t hint)
- {
- this->set_buffer_hint(hint);
- this->start();
- }
-
- //! Combined hint + run
- void run(const size_t hint)
- {
- this->set_buffer_hint(hint);
- this->run();
- }
+ void commit(void);
/*!
* Run is for finite flow graph executions.
diff --git a/lib/top_block.cpp b/lib/top_block.cpp
index f5d4517..c93bda5 100644
--- a/lib/top_block.cpp
+++ b/lib/top_block.cpp
@@ -20,6 +20,11 @@
using namespace gnuradio;
+GlobalBlockConfig::GlobalBlockConfig(void)
+{
+ maximum_output_items = 0;
+}
+
TopBlock::TopBlock(void)
{
//NOP
@@ -48,18 +53,11 @@ void ElementImpl::top_block_cleanup(void)
<< std::flush;
}
-void TopBlock::update(void)
+void TopBlock::commit(void)
{
this->start(); //ok to re-start, means update
}
-void TopBlock::set_buffer_hint(const size_t hint)
-{
- TopHintMessage message;
- message.hint = hint;
- (*this)->executor->post_all(message);
-}
-
void TopBlock::start(void)
{
(*this)->executor->commit();