diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/top_block.cpp | 14 |
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(); +} |