summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2012-09-11 20:33:58 -0700
committerJosh Blum2012-09-11 20:33:58 -0700
commita822c2f3063030d9af172c4d3798885f3281d44e (patch)
treebe2687bd3812b159031ff9a7b115b612c8f36bdd /lib
parent42682f091b9c80b54c3b95b27bb496acc46ce294 (diff)
downloadsandhi-a822c2f3063030d9af172c4d3798885f3281d44e.tar.gz
sandhi-a822c2f3063030d9af172c4d3798885f3281d44e.tar.bz2
sandhi-a822c2f3063030d9af172c4d3798885f3281d44e.zip
added wait w/ timeout to top block/executor
Diffstat (limited to 'lib')
-rw-r--r--lib/top_block.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/top_block.cpp b/lib/top_block.cpp
index 306e152..f3e1fc8 100644
--- a/lib/top_block.cpp
+++ b/lib/top_block.cpp
@@ -118,3 +118,17 @@ void TopBlock::wait(void)
boost::this_thread::yield();
}
}
+
+bool TopBlock::wait(const double timeout)
+{
+ const boost::system_time exit_time = boost::get_system_time() +
+ boost::posix_time::microseconds(long(timeout*1e6));
+
+ //wait for all blocks to release the token
+ while (not (*this)->token.unique() or boost::get_system_time() < exit_time)
+ {
+ boost::this_thread::yield();
+ }
+
+ return (*this)->token.unique();
+}