diff options
author | Josh Blum | 2012-12-20 01:18:02 -0800 |
---|---|---|
committer | Josh Blum | 2012-12-20 01:18:02 -0800 |
commit | 9d81f8cc1feab93b0ed77d65e02adbf44266638f (patch) | |
tree | 4902785296f2837349012b4cbcfd20edd60bc341 | |
parent | 59d8dafe387b11ecf8bfff892e1e30fe07e33caa (diff) | |
parent | df762132b957fe171a597512849b5c29e3b4b691 (diff) | |
download | sandhi-9d81f8cc1feab93b0ed77d65e02adbf44266638f.tar.gz sandhi-9d81f8cc1feab93b0ed77d65e02adbf44266638f.tar.bz2 sandhi-9d81f8cc1feab93b0ed77d65e02adbf44266638f.zip |
Merge branch 'debug_work'
m--------- | PMC | 0 | ||||
-rw-r--r-- | lib/block.cpp | 19 | ||||
-rw-r--r-- | lib/element.cpp | 3 | ||||
-rw-r--r-- | lib/element_impl.hpp | 1 |
4 files changed, 20 insertions, 3 deletions
diff --git a/PMC b/PMC -Subproject bb89b7be4a7912c885d8bd9eace76a0f2e9fe2a +Subproject cc42002165934e8a8800b0265ee5fe9707583f0 diff --git a/lib/block.cpp b/lib/block.cpp index 4f7c7c9..85f7654 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -3,6 +3,7 @@ #include "element_impl.hpp" #include <gras/block.hpp> #include <boost/foreach.hpp> +#include <boost/thread/thread.hpp> //yield using namespace gras; @@ -28,7 +29,7 @@ Block::Block(void) Block::Block(const std::string &name): Element(name) { - (*this)->block = boost::shared_ptr<BlockActor>(new BlockActor()); + (*this)->block.reset(new BlockActor()); (*this)->thread_pool = (*this)->block->thread_pool; //ref copy of pool (*this)->block->name = name; //for debug purposes @@ -44,6 +45,22 @@ Block::Block(const std::string &name): this->set_buffer_affinity(-1); } +void ElementImpl::block_cleanup(void) +{ + //wait for actor to chew through enqueued messages + while (this->block->GetNumQueuedMessages()) + { + //TODO timeout if this does not stop + boost::this_thread::yield(); + } + + //delete the actor + this->block.reset(); + + //unref actor's framework + this->thread_pool.reset(); //must be deleted after actor +} + template <typename V, typename T> void vector_set(V &v, const T &t, const size_t index) { diff --git a/lib/element.cpp b/lib/element.cpp index d623183..27a5db0 100644 --- a/lib/element.cpp +++ b/lib/element.cpp @@ -32,8 +32,7 @@ ElementImpl::~ElementImpl(void) { if (this->executor) this->top_block_cleanup(); if (this->topology) this->hier_block_cleanup(); - this->block.reset(); - this->thread_pool.reset(); //must be deleted after actor + if (this->block) this->block_cleanup(); } Element &Element::shared_to_element(void) diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp index 6376b89..5c2d998 100644 --- a/lib/element_impl.hpp +++ b/lib/element_impl.hpp @@ -21,6 +21,7 @@ struct ElementImpl ~ElementImpl(void); void top_block_cleanup(void); void hier_block_cleanup(void); + void block_cleanup(void); //common element properties std::string name; |