summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Blum2013-06-06 13:01:04 -0700
committerJosh Blum2013-06-06 13:01:04 -0700
commit7350e18b8d5090349390f54b76a0e251b66ce619 (patch)
tree6ce12ebd668d120823c652f8b09d055a149d70dc
parent3739e119b81f0898755817eff618d45eed7e6692 (diff)
downloadsandhi-7350e18b8d5090349390f54b76a0e251b66ce619.tar.gz
sandhi-7350e18b8d5090349390f54b76a0e251b66ce619.tar.bz2
sandhi-7350e18b8d5090349390f54b76a0e251b66ce619.zip
gras: moved block ptr into data
-rw-r--r--lib/block.cpp8
-rw-r--r--lib/block_allocator.cpp2
-rw-r--r--lib/block_handlers.cpp4
-rw-r--r--lib/block_props.cpp2
-rw-r--r--lib/element.cpp2
-rw-r--r--lib/element_impl.hpp3
-rw-r--r--lib/gras_impl/block_actor.hpp3
-rw-r--r--lib/gras_impl/block_data.hpp4
-rw-r--r--lib/gras_impl/debug.hpp2
-rw-r--r--lib/input_handlers.cpp2
-rw-r--r--lib/tag_handlers.hpp2
-rw-r--r--lib/task_done.cpp4
-rw-r--r--lib/top_block_query.cpp6
-rw-r--r--lib/topology_handler.cpp2
14 files changed, 25 insertions, 21 deletions
diff --git a/lib/block.cpp b/lib/block.cpp
index a7b31f7..00238ba 100644
--- a/lib/block.cpp
+++ b/lib/block.cpp
@@ -34,11 +34,12 @@ Block::Block(const std::string &name):
{
//create non-actor containers
(*this)->block_data.reset(new BlockData());
+ (*this)->block_data->block = this;
(*this)->worker.reset(new Apology::Worker());
//create actor and init members
(*this)->block_actor.reset(new BlockActor());
- (*this)->setup_actor(this);
+ (*this)->setup_actor();
//setup some state variables
(*this)->block_data->block_state = BLOCK_STATE_INIT;
@@ -53,11 +54,10 @@ Block::~Block(void)
//NOP
}
-void ElementImpl::setup_actor(Block *block_ptr)
+void ElementImpl::setup_actor(void)
{
this->block_actor->worker = this->worker.get();
this->block_actor->name = name; //for debug purposes
- this->block_actor->block_ptr = block_ptr;
this->block_actor->data = this->block_data;
this->worker->set_actor(this->block_actor.get());
this->thread_pool = this->block_actor->thread_pool; //ref copy of pool
@@ -199,7 +199,7 @@ void Block::set_thread_pool(const ThreadPool &thread_pool)
{
boost::shared_ptr<BlockActor> old_actor = (*this)->block_actor;
(*this)->block_actor.reset(new BlockActor(thread_pool));
- (*this)->setup_actor(this);
+ (*this)->setup_actor();
wait_actor_idle((*this)->repr, *old_actor);
}
diff --git a/lib/block_allocator.cpp b/lib/block_allocator.cpp
index 3ac65df..aa97405 100644
--- a/lib/block_allocator.cpp
+++ b/lib/block_allocator.cpp
@@ -77,7 +77,7 @@ void BlockActor::handle_top_alloc(const TopAllocMessage &, const Theron::Address
config.affinity = data->buffer_affinity;
config.token = token;
- BufferQueueSptr queue = block_ptr->output_buffer_allocator(i, config);
+ BufferQueueSptr queue = data->block->output_buffer_allocator(i, config);
data->output_queues.set_buffer_queue(i, queue);
InputAllocMessage message;
diff --git a/lib/block_handlers.cpp b/lib/block_handlers.cpp
index e2fd71b..c52d974 100644
--- a/lib/block_handlers.cpp
+++ b/lib/block_handlers.cpp
@@ -15,7 +15,7 @@ void BlockActor::handle_top_active(
if (data->block_state != BLOCK_STATE_LIVE)
{
- block_ptr->notify_active();
+ data->block->notify_active();
data->stats.start_time = time_now();
}
data->block_state = BLOCK_STATE_LIVE;
@@ -154,7 +154,7 @@ void BlockActor::handle_get_stats(
//create the message reply object
GetStatsMessage message;
- message.block_id = block_ptr->get_uid();
+ message.block_id = data->block->get_uid();
message.stats = data->stats;
message.stats_time = time_now();
diff --git a/lib/block_props.cpp b/lib/block_props.cpp
index 3fb381e..a85d948 100644
--- a/lib/block_props.cpp
+++ b/lib/block_props.cpp
@@ -24,7 +24,7 @@ void BlockActor::handle_prop_access(
//call into the handler overload to do the property access
try
{
- reply.value = block_ptr->_handle_prop_access(message.key, message.value, message.set);
+ reply.value = data->block->_handle_prop_access(message.key, message.value, message.set);
}
catch (const std::exception &e)
{
diff --git a/lib/element.cpp b/lib/element.cpp
index 39c1f02..4b73bd4 100644
--- a/lib/element.cpp
+++ b/lib/element.cpp
@@ -138,5 +138,5 @@ Block *Element::locate_block(const std::string &path)
}
//return block ptr as result
- return elem->block_actor->block_ptr;
+ return elem->block_data->block;
}
diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp
index 6d9e551..23f7127 100644
--- a/lib/element_impl.hpp
+++ b/lib/element_impl.hpp
@@ -19,6 +19,8 @@ namespace gras
struct ElementImpl
{
+ //setup stuff
+ void setup_actor(void);
//deconstructor stuff
~ElementImpl(void);
@@ -48,7 +50,6 @@ struct ElementImpl
boost::shared_ptr<Apology::Executor> executor;
boost::shared_ptr<BlockActor> block_actor;
boost::shared_ptr<BlockData> block_data;
- void setup_actor(Block *block_ptr);
ThreadPool thread_pool;
Apology::Base *get_elem(void) const
{
diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp
index 360c352..90e96bb 100644
--- a/lib/gras_impl/block_actor.hpp
+++ b/lib/gras_impl/block_actor.hpp
@@ -18,7 +18,6 @@ struct BlockActor : Theron::Actor
{
BlockActor(const ThreadPool &tp = ThreadPool());
~BlockActor(void);
- Block *block_ptr;
std::string name; //for debug
ThreadPool thread_pool;
Token prio_token;
@@ -104,7 +103,7 @@ struct BlockActor : Theron::Actor
//work helpers
inline void task_work(void)
{
- block_ptr->work(data->input_items, data->output_items);
+ data->block->work(data->input_items, data->output_items);
}
//property stuff
diff --git a/lib/gras_impl/block_data.hpp b/lib/gras_impl/block_data.hpp
index 9fbf3eb..4b6e8de 100644
--- a/lib/gras_impl/block_data.hpp
+++ b/lib/gras_impl/block_data.hpp
@@ -3,6 +3,7 @@
#ifndef INCLUDED_LIBGRAS_IMPL_BLOCK_DATA_HPP
#define INCLUDED_LIBGRAS_IMPL_BLOCK_DATA_HPP
+#include <gras/block.hpp>
#include <gras_impl/debug.hpp>
#include <gras_impl/bitset.hpp>
#include <gras_impl/token.hpp>
@@ -33,6 +34,9 @@ enum BlockState
struct BlockData
{
+ //block pointer to call into parent
+ Block *block;
+
//per port properties
std::vector<InputPortConfig> input_configs;
std::vector<OutputPortConfig> output_configs;
diff --git a/lib/gras_impl/debug.hpp b/lib/gras_impl/debug.hpp
index 04480d8..eb09090 100644
--- a/lib/gras_impl/debug.hpp
+++ b/lib/gras_impl/debug.hpp
@@ -48,7 +48,7 @@ extern void *operator new(std::size_t n) throw (std::bad_alloc);
#define VAR(x) std::cerr << #x << " = " << (x) << std::endl << std::flush;
#ifdef MESSAGE_TRACING
-#define MESSAGE_TRACER() std::cerr << block_ptr->to_string() << " in " << BOOST_CURRENT_FUNCTION << std::endl << std::flush;
+#define MESSAGE_TRACER() std::cerr << name << " in " << BOOST_CURRENT_FUNCTION << std::endl << std::flush;
#else
#define MESSAGE_TRACER()
#endif
diff --git a/lib/input_handlers.cpp b/lib/input_handlers.cpp
index c3d4936..89e1d34 100644
--- a/lib/input_handlers.cpp
+++ b/lib/input_handlers.cpp
@@ -82,7 +82,7 @@ void BlockActor::handle_input_alloc(const InputAllocMessage &message, const Ther
//handle the upstream block allocation request
OutputAllocMessage new_msg;
- new_msg.queue = block_ptr->input_buffer_allocator(index, message.config);
+ new_msg.queue = data->block->input_buffer_allocator(index, message.config);
if (new_msg.queue) worker->post_upstream(index, new_msg);
}
diff --git a/lib/tag_handlers.hpp b/lib/tag_handlers.hpp
index cc03a9b..a52b70e 100644
--- a/lib/tag_handlers.hpp
+++ b/lib/tag_handlers.hpp
@@ -35,7 +35,7 @@ GRAS_FORCE_INLINE void BlockActor::trim_tags(const size_t i)
if GRAS_LIKELY(last == 0) return;
//call the overloaded propagate_tags to do the dirty work
- block_ptr->propagate_tags(i, TagIter(tags_i.begin(), tags_i.begin()+last));
+ data->block->propagate_tags(i, TagIter(tags_i.begin(), tags_i.begin()+last));
//now its safe to perform the erasure
tags_i.erase(tags_i.begin(), tags_i.begin()+last);
diff --git a/lib/task_done.cpp b/lib/task_done.cpp
index 3d4262d..999fd2c 100644
--- a/lib/task_done.cpp
+++ b/lib/task_done.cpp
@@ -15,7 +15,7 @@ void BlockActor::mark_done(void)
if (data->block_state == BLOCK_STATE_DONE) return; //can re-enter checking done first
data->stats.stop_time = time_now();
- block_ptr->notify_inactive();
+ data->block->notify_inactive();
//flush partial output buffers to the downstream
for (size_t i = 0; i < worker->get_num_outputs(); i++)
@@ -62,7 +62,7 @@ void BlockActor::mark_done(void)
if (ARMAGEDDON) std::cerr
<< "==================================================\n"
- << "== The " << block_ptr->to_string() << " is done...\n"
+ << "== The " << name << " is done...\n"
<< "==================================================\n"
<< std::flush;
}
diff --git a/lib/top_block_query.cpp b/lib/top_block_query.cpp
index a0a3216..79dadfb 100644
--- a/lib/top_block_query.cpp
+++ b/lib/top_block_query.cpp
@@ -56,7 +56,7 @@ static ptree query_blocks(ElementImpl *self, const ptree &)
block_attrs.push_back(std::make_pair(p.first, prop_attrs));
prop_e.push_back(std::make_pair("props", block_attrs));
}
- e.push_back(std::make_pair(actor->block_ptr->get_uid(), prop_e));
+ e.push_back(std::make_pair(actor->data->block->get_uid(), prop_e));
}
root.push_back(std::make_pair("blocks", e));
return root;
@@ -82,7 +82,7 @@ static ptree query_stats(ElementImpl *self, const ptree &query)
BlockActor *actor = dynamic_cast<BlockActor *>(w->get_actor());
//filter workers not needed in query
- const std::string id = actor->block_ptr->get_uid();
+ const std::string id = actor->data->block->get_uid();
if (std::find(block_ids.begin(), block_ids.end(), id) == block_ids.end()) continue;
//send a message to the block's actor to query stats
@@ -174,7 +174,7 @@ static ptree query_props(ElementImpl *self, const ptree &query)
BOOST_FOREACH(Apology::Worker *w, self->executor->get_workers())
{
BlockActor *actor = dynamic_cast<BlockActor *>(w->get_actor());
- if (actor->block_ptr->get_uid() != block_id) continue;
+ if (actor->data->block->get_uid() != block_id) continue;
if (set)
{
const std::type_info &t = actor->data->property_registry[prop_key].setter->type();
diff --git a/lib/topology_handler.cpp b/lib/topology_handler.cpp
index 07df34d..1586f9d 100644
--- a/lib/topology_handler.cpp
+++ b/lib/topology_handler.cpp
@@ -28,7 +28,7 @@ void BlockActor::handle_topology(
const size_t num_outputs = worker->get_num_outputs();
//call notify_topology on block before committing settings
- block_ptr->notify_topology(num_inputs, num_outputs);
+ data->block->notify_topology(num_inputs, num_outputs);
//resize and fill port properties
resize_fill_back(data->input_configs, num_inputs);