diff options
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 4 | ||||
-rw-r--r-- | host/lib/utils/tasks.cpp | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index b621c4c25..932655eff 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -132,9 +132,7 @@ public: boost::uint32_t curr_secs = this->peek32(U2_REG_TIME64_SECS_RB_IMM); this->get_reg<boost::uint32_t, USRP2_REG_ACTION_FW_POKE32>(U2_FW_REG_LOCK_TIME, curr_secs); //sleep for a bit - try{//HACK this try/catch is a work-around for when sleep throws something other than thread_interrupted - boost::this_thread::sleep(boost::posix_time::milliseconds(1500)); - }catch(...){throw boost::thread_interrupted();} + boost::this_thread::sleep(boost::posix_time::milliseconds(500)); } /*********************************************************************** diff --git a/host/lib/utils/tasks.cpp b/host/lib/utils/tasks.cpp index ef56bb2de..993b484ea 100644 --- a/host/lib/utils/tasks.cpp +++ b/host/lib/utils/tasks.cpp @@ -34,6 +34,7 @@ public: } ~task_impl(void){ + _running = false; _thread_group.interrupt_all(); _thread_group.join_all(); } @@ -41,10 +42,11 @@ public: private: void task_loop(const task_fcn_type &task_fcn, boost::barrier &spawn_barrier){ + _running = true; spawn_barrier.wait(); try{ - while (not boost::this_thread::interruption_requested()){ + while (_running){ task_fcn(); } } @@ -55,7 +57,9 @@ private: do_error_msg(e.what()); } catch(...){ - do_error_msg("unknown exception"); + //FIXME + //Unfortunately, this is also an ok way to end a task, + //because on some systems boost throws uncatchables. } } @@ -68,6 +72,7 @@ private: } boost::thread_group _thread_group; + bool _running; }; task::sptr task::make(const task_fcn_type &task_fcn){ |