Loading adb/adb_utils.h +9 −4 Original line number Original line Diff line number Diff line Loading @@ -74,13 +74,18 @@ class BlockingQueue { template <typename Fn> template <typename Fn> void PopAll(Fn fn) { void PopAll(Fn fn) { std::vector<T> popped; { std::unique_lock<std::mutex> lock(mutex); std::unique_lock<std::mutex> lock(mutex); cv.wait(lock, [this]() { return !queue.empty(); }); cv.wait(lock, [this]() { return !queue.empty(); }); popped = std::move(queue); queue.clear(); } for (const T& t : queue) { for (const T& t : popped) { fn(t); fn(t); } } queue.clear(); } } }; }; Loading adb/client/usb_libusb.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -422,8 +422,10 @@ static void device_disconnected(libusb_device* device) { if (!it->second->device_handle) { if (!it->second->device_handle) { // If the handle is null, we were never able to open the device. // If the handle is null, we were never able to open the device. unregister_usb_transport(it->second.get()); unregister_usb_transport(it->second.get()); } usb_handles.erase(it); usb_handles.erase(it); } else { // Closure of the transport will erase the usb_handle. } } } } } Loading Loading
adb/adb_utils.h +9 −4 Original line number Original line Diff line number Diff line Loading @@ -74,13 +74,18 @@ class BlockingQueue { template <typename Fn> template <typename Fn> void PopAll(Fn fn) { void PopAll(Fn fn) { std::vector<T> popped; { std::unique_lock<std::mutex> lock(mutex); std::unique_lock<std::mutex> lock(mutex); cv.wait(lock, [this]() { return !queue.empty(); }); cv.wait(lock, [this]() { return !queue.empty(); }); popped = std::move(queue); queue.clear(); } for (const T& t : queue) { for (const T& t : popped) { fn(t); fn(t); } } queue.clear(); } } }; }; Loading
adb/client/usb_libusb.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -422,8 +422,10 @@ static void device_disconnected(libusb_device* device) { if (!it->second->device_handle) { if (!it->second->device_handle) { // If the handle is null, we were never able to open the device. // If the handle is null, we were never able to open the device. unregister_usb_transport(it->second.get()); unregister_usb_transport(it->second.get()); } usb_handles.erase(it); usb_handles.erase(it); } else { // Closure of the transport will erase the usb_handle. } } } } } Loading