summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib
diff options
context:
space:
mode:
authorJacob Gilbert <mrjacobagilbert@gmail.com>2020-09-28 08:58:50 -0700
committermormj <34754695+mormj@users.noreply.github.com>2020-09-30 06:17:05 -0400
commit22e210bd5a165ba8db4767e2a4214b6e4bf4ac33 (patch)
tree7b630c4d9477f300b069913a742ece4ee2c023dd /gnuradio-runtime/lib
parentc196dacea56ef938902646a2143907858415b240 (diff)
runtime: fix latency issue caused by setting block alias on message block
This changes how the blocks are identified when they need to be notified that they have messages waiting. It also clarifies the name the block is registered with explicitly, and adds exceptions for looking up blocks that do not exist.
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r--gnuradio-runtime/lib/basic_block.cc2
-rw-r--r--gnuradio-runtime/lib/block.cc4
-rw-r--r--gnuradio-runtime/lib/block_registry.cc8
3 files changed, 9 insertions, 5 deletions
diff --git a/gnuradio-runtime/lib/basic_block.cc b/gnuradio-runtime/lib/basic_block.cc
index c6ac346d11..f3a06476b4 100644
--- a/gnuradio-runtime/lib/basic_block.cc
+++ b/gnuradio-runtime/lib/basic_block.cc
@@ -188,7 +188,7 @@ void basic_block::insert_tail(pmt::pmt_t which_port, pmt::pmt_t msg)
msg_queue_ready[which_port]->notify_one();
// wake up thread if BLKD_IN or BLKD_OUT
- global_block_registry.notify_blk(alias());
+ global_block_registry.notify_blk(d_symbol_name);
}
pmt::pmt_t basic_block::delete_head_nowait(pmt::pmt_t which_port)
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index b6137f7a51..e9f1a635bb 100644
--- a/gnuradio-runtime/lib/block.cc
+++ b/gnuradio-runtime/lib/block.cc
@@ -47,7 +47,7 @@ block::block(const std::string& name,
d_pmt_done(pmt::intern("done")),
d_system_port(pmt::intern("system"))
{
- global_block_registry.register_primitive(alias(), this);
+ global_block_registry.register_primitive(d_symbol_name, this);
message_port_register_in(d_system_port);
set_msg_handler(d_system_port, [this](pmt::pmt_t msg) { this->system_handler(msg); });
}
@@ -598,7 +598,7 @@ void block::system_handler(pmt::pmt_t msg)
pmt::pmt_t op = pmt::car(msg);
if (pmt::eqv(op, d_pmt_done)) {
d_finished = pmt::to_long(pmt::cdr(msg));
- global_block_registry.notify_blk(alias());
+ global_block_registry.notify_blk(d_symbol_name);
} else {
std::cout << "WARNING: bad message op on system port!\n";
pmt::print(msg);
diff --git a/gnuradio-runtime/lib/block_registry.cc b/gnuradio-runtime/lib/block_registry.cc
index 0a426f18b2..4c3f20ba2b 100644
--- a/gnuradio-runtime/lib/block_registry.cc
+++ b/gnuradio-runtime/lib/block_registry.cc
@@ -120,10 +120,14 @@ void block_registry::notify_blk(std::string blk)
gr::thread::scoped_lock guard(d_mutex);
if (primitive_map.find(blk) == primitive_map.end()) {
- return;
+ throw std::runtime_error("block notify failed: block not found!");
}
- if (primitive_map[blk]->detail().get())
+ if (primitive_map[blk]->detail().get()) {
primitive_map[blk]->detail()->d_tpb.notify_msg();
+ } else {
+ // not having block detail is not necessarily a problem; this will happen when
+ // publishing a message to a block that exists but has not yet been started
+ }
}
} /* namespace gr */