From 976e7c8ff8dcf980ccaa9460384ceae395a1ddb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 3 Aug 2021 13:39:15 +0400 Subject: [PATCH] Add Context::interrupt_handle_events() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- libusb1-sys/src/lib.rs | 1 + src/context.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/libusb1-sys/src/lib.rs b/libusb1-sys/src/lib.rs index 2f9118d..5350566 100644 --- a/libusb1-sys/src/lib.rs +++ b/libusb1-sys/src/lib.rs @@ -426,6 +426,7 @@ extern "system" { completed: *mut c_int, ) -> c_int; pub fn libusb_handle_events_locked(context: *mut libusb_context, tv: *const timeval) -> c_int; + pub fn libusb_interrupt_event_handler(context: *mut libusb_context); pub fn libusb_try_lock_events(context: *mut libusb_context) -> c_int; pub fn libusb_lock_events(context: *mut libusb_context); diff --git a/src/context.rs b/src/context.rs index c419405..d8b6df2 100644 --- a/src/context.rs +++ b/src/context.rs @@ -190,6 +190,12 @@ pub trait UsbContext: Clone + Sized + Send + Sync { } } + fn interrupt_handle_events(&self) { + unsafe { + libusb_interrupt_event_handler(self.as_raw()) + } + } + fn next_timeout(&self) -> crate::Result> { let mut tv = timeval { tv_sec: 0, tv_usec: 0 }; let n = unsafe {