summaryrefslogtreecommitdiff
path: root/lib/block.cpp
diff options
context:
space:
mode:
authorJosh Blum2012-12-20 01:18:02 -0800
committerJosh Blum2012-12-20 01:18:02 -0800
commit9d81f8cc1feab93b0ed77d65e02adbf44266638f (patch)
tree4902785296f2837349012b4cbcfd20edd60bc341 /lib/block.cpp
parent59d8dafe387b11ecf8bfff892e1e30fe07e33caa (diff)
parentdf762132b957fe171a597512849b5c29e3b4b691 (diff)
downloadsandhi-9d81f8cc1feab93b0ed77d65e02adbf44266638f.tar.gz
sandhi-9d81f8cc1feab93b0ed77d65e02adbf44266638f.tar.bz2
sandhi-9d81f8cc1feab93b0ed77d65e02adbf44266638f.zip
Merge branch 'debug_work'
Diffstat (limited to 'lib/block.cpp')
-rw-r--r--lib/block.cpp19
1 files changed, 18 insertions, 1 deletions
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)
{