diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2015-01-15 20:50:55 +0100 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2015-01-15 20:58:04 +0100 |
commit | 2d755af9cd2668a3a8f55bd14c8b598234729957 (patch) | |
tree | e3d3ff761ebbddb57205b98b9fff226573c49357 /gnuradio-runtime/lib/basic_block.cc | |
parent | 6c121388075c9d7624bef832a5dd835da73798cc (diff) |
runtime: Add a timeout option on basic_block::delete_head_blocking
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'gnuradio-runtime/lib/basic_block.cc')
-rw-r--r-- | gnuradio-runtime/lib/basic_block.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gnuradio-runtime/lib/basic_block.cc b/gnuradio-runtime/lib/basic_block.cc index 09d2eb2b3a..082d0753c8 100644 --- a/gnuradio-runtime/lib/basic_block.cc +++ b/gnuradio-runtime/lib/basic_block.cc @@ -228,12 +228,21 @@ namespace gr { } pmt::pmt_t - basic_block::delete_head_blocking(pmt::pmt_t which_port) + basic_block::delete_head_blocking(pmt::pmt_t which_port, unsigned int millisec) { gr::thread::scoped_lock guard(mutex); - while(empty_p(which_port)) { - msg_queue_ready[which_port]->wait(guard); + if (millisec) { + boost::system_time const timeout = boost::get_system_time() + boost::posix_time::milliseconds(millisec); + while (empty_p(which_port)) { + if (!msg_queue_ready[which_port]->timed_wait(guard, timeout)) { + return pmt::pmt_t(); + } + } + } else { + while(empty_p(which_port)) { + msg_queue_ready[which_port]->wait(guard); + } } pmt::pmt_t m(msg_queue[which_port].front()); |