summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------gnuradio0
m---------grextras0
-rw-r--r--include/gras/block.i2
-rw-r--r--include/gras/detail/block.hpp3
-rw-r--r--include/gras/element.i22
-rw-r--r--include/gras/hier_block.i2
-rw-r--r--lib/block_task.cpp4
-rw-r--r--lib/gras_impl/block_actor.hpp7
-rw-r--r--lib/input_handlers.cpp21
-rw-r--r--python/gras/GRAS_Block.i1
-rw-r--r--python/gras/GRAS_HierBlock.i1
11 files changed, 35 insertions, 28 deletions
diff --git a/gnuradio b/gnuradio
-Subproject 78ccc760124713a56c9c85729ac40844a97f055
+Subproject 993ff9e8c1050bad327041132828370986a72b2
diff --git a/grextras b/grextras
-Subproject 8bf9d4879128dd8c881bf3739f99dcb089a6a56
+Subproject 7a846afe69236e55ba7b7e1d20224c35aa8751e
diff --git a/include/gras/block.i b/include/gras/block.i
index 10ef70c..8e1a635 100644
--- a/include/gras/block.i
+++ b/include/gras/block.i
@@ -7,7 +7,7 @@
#include <gras/block.hpp>
%}
-%include <gras/element.i>
+%import <gras/element.i>
%import <gras/tags.i>
%include <gras/tag_iter.i>
%import <gras/sbuffer.i>
diff --git a/include/gras/detail/block.hpp b/include/gras/detail/block.hpp
index 2a48080..ba3455c 100644
--- a/include/gras/detail/block.hpp
+++ b/include/gras/detail/block.hpp
@@ -58,8 +58,9 @@ inline void Block::register_property(
void(ClassType::*set)(const ValueType &)
)
{
+ ClassType *obj = dynamic_cast<ClassType *>(this);
PropertyRegistrySptr pr;
- pr.reset(new PropertyRegistryImpl<ClassType, ValueType>((ClassType *)this, get, set));
+ pr.reset(new PropertyRegistryImpl<ClassType, ValueType>(obj, get, set));
this->_register_property(key, PMC_M(pr));
}
diff --git a/include/gras/element.i b/include/gras/element.i
index 1408eac..be3814e 100644
--- a/include/gras/element.i
+++ b/include/gras/element.i
@@ -34,23 +34,25 @@
////////////////////////////////////////////////////////////////////////
// Operator overloads for Element
////////////////////////////////////////////////////////////////////////
-%extend gras::Element
+%{
+
+inline bool gras_element_equal(const gras::Element &lhs, const gras::Element &rhs)
{
- std::string __str__(void) const
- {
- return ($self)->to_string();
- }
+ return lhs.get() == rhs.get();
+}
- bool _equal(const Element &rhs) const
- {
- return ($self)->get() == rhs.get();
- }
+%}
+%extend gras::Element
+{
%insert("python")
%{
def __eq__(self, rhs):
if not isinstance(rhs, Element): return False
- return self._equal(rhs)
+ return gras_element_equal(self, rhs)
+
+ def __str__(self):
+ return self.to_string()
%}
}
diff --git a/include/gras/hier_block.i b/include/gras/hier_block.i
index 67cf74e..da57e3d 100644
--- a/include/gras/hier_block.i
+++ b/include/gras/hier_block.i
@@ -7,7 +7,7 @@
#include <gras/hier_block.hpp>
%}
-%include <gras/element.i>
+%import <gras/element.i>
%include <gras/hier_block.hpp>
#endif /*INCLUDED_GRAS_HIER_BLOCK_I*/
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index 21986fc..cc707a8 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -211,9 +211,7 @@ void BlockActor::handle_task(void)
this->trim_msgs(i);
//update the inputs available bit field
- const bool has_input_bufs = not this->input_queues.empty(i);
- const bool has_input_msgs = not this->input_msgs[i].empty();
- this->inputs_available.set(i, has_input_bufs or has_input_msgs);
+ this->update_input_avail(i);
//missing at least one upstream provider?
//since nothing else is coming in, its safe to mark done
diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp
index 9006d6e..e620d77 100644
--- a/lib/gras_impl/block_actor.hpp
+++ b/lib/gras_impl/block_actor.hpp
@@ -130,6 +130,13 @@ struct BlockActor : Apology::Worker
if (this->is_work_allowed()) this->Send(SelfKickMessage(), this->GetAddress());
}
+ GRAS_FORCE_INLINE void update_input_avail(const size_t i)
+ {
+ const bool has_input_bufs = not this->input_queues.empty(i) and this->input_queues.ready(i);
+ const bool has_input_msgs = not this->input_msgs[i].empty();
+ this->inputs_available.set(i, has_input_bufs or has_input_msgs);
+ }
+
GRAS_FORCE_INLINE bool is_input_done(const size_t i)
{
return this->inputs_done[i] and not this->inputs_available[i];
diff --git a/lib/input_handlers.cpp b/lib/input_handlers.cpp
index 27704fe..4702329 100644
--- a/lib/input_handlers.cpp
+++ b/lib/input_handlers.cpp
@@ -37,7 +37,7 @@ void BlockActor::handle_input_msg(const InputMsgMessage &message, const Theron::
//handle incoming async message, push into the msg storage
if (this->block_state == BLOCK_STATE_DONE) return;
this->input_msgs[index].push_back(message.msg);
- this->inputs_available.set(index);
+ this->update_input_avail(index);
ta.done();
this->handle_task();
@@ -52,7 +52,7 @@ void BlockActor::handle_input_buffer(const InputBufferMessage &message, const Th
//handle incoming stream buffer, push into the queue
if (this->block_state == BLOCK_STATE_DONE) return;
this->input_queues.push(index, message.buffer);
- this->inputs_available.set(index);
+ this->update_input_avail(index);
ta.done();
this->handle_task();
@@ -76,16 +76,13 @@ void BlockActor::handle_input_check(const InputCheckMessage &message, const Ther
//an upstream block declared itself done, recheck the token
this->inputs_done.set(index, this->input_tokens[index].unique());
- if (this->is_input_done(index)) //missing an upstream provider
- {
- this->mark_done();
- }
- //or re-enter handle task so fail logic can mark done
- else
- {
- ta.done();
- this->handle_task();
- }
+
+ //upstream done, give it one more attempt at task handling
+ ta.done();
+ this->handle_task();
+
+ //now recheck the status, mark block done if the input is done
+ if (this->is_input_done(index)) this->mark_done();
}
void BlockActor::handle_input_alloc(const InputAllocMessage &message, const Theron::Address)
diff --git a/python/gras/GRAS_Block.i b/python/gras/GRAS_Block.i
index 84d6548..82c5d78 100644
--- a/python/gras/GRAS_Block.i
+++ b/python/gras/GRAS_Block.i
@@ -58,6 +58,7 @@
#include <iostream>
%}
+%include <gras/element.i>
%include <gras/block.i>
////////////////////////////////////////////////////////////////////////
diff --git a/python/gras/GRAS_HierBlock.i b/python/gras/GRAS_HierBlock.i
index 21d087e..4afe8fe 100644
--- a/python/gras/GRAS_HierBlock.i
+++ b/python/gras/GRAS_HierBlock.i
@@ -25,6 +25,7 @@
////////////////////////////////////////////////////////////////////////
// pull in hier and top interface
////////////////////////////////////////////////////////////////////////
+%include <gras/element.i>
%include <gras/hier_block.i>
%include <gras/top_block.hpp>