diff options
author | Josh Blum <josh@joshknows.com> | 2011-01-17 14:01:35 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-01-17 14:01:35 -0800 |
commit | 07710a5f68f0b313f4257551dd469d7ccf938213 (patch) | |
tree | 18766219573df79bb5adcd98b242d2fbad395654 /host/lib/transport | |
parent | d521bd1c28acf0ca159f8c84a8189bef11fdf65d (diff) | |
download | uhd-07710a5f68f0b313f4257551dd469d7ccf938213.tar.gz uhd-07710a5f68f0b313f4257551dd469d7ccf938213.tar.bz2 uhd-07710a5f68f0b313f4257551dd469d7ccf938213.zip |
usb: use thread interruption in usb zero copy on deconstruction
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/libusb1_zero_copy.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 806d923e9..adc590284 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -134,7 +134,6 @@ static void callback(libusb_transfer *lut){ * \param pointer to libusb_transfer */ void usb_endpoint::callback_handle_transfer(libusb_transfer *lut){ - boost::this_thread::disable_interruption di; //disable because the wait can throw _completed_list->push_with_wait(lut); } @@ -272,7 +271,6 @@ void usb_endpoint::print_transfer_status(libusb_transfer *lut){ } libusb_transfer *usb_endpoint::get_lut_with_wait(double timeout){ - boost::this_thread::disable_interruption di; //disable because the wait can throw libusb_transfer *lut; if (_completed_list->pop_with_timed_wait(lut, timeout)) return lut; return NULL; @@ -293,6 +291,7 @@ public: ~libusb_zero_copy_impl(void){ _threads_running = false; + _thread_group.interrupt_all(); _thread_group.join_all(); } @@ -333,12 +332,14 @@ private: set_thread_priority_safe(); libusb::session::sptr session = libusb::session::get_global_session(); _threads_running = true; - while(_threads_running){ - timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 100000; //100ms - libusb_handle_events_timeout(session->get_context(), &tv); - } + try{ + while(_threads_running){ + timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 100000; //100ms + libusb_handle_events_timeout(session->get_context(), &tv); + } + } catch(const boost::thread_interrupted &){} } }; |