mirror of https://github.com/rusefi/usb4java.git
Implement interruptEventHandler
This commit is contained in:
parent
7ab6e6d3ed
commit
b24618df0f
|
@ -13,7 +13,7 @@
|
|||
Add missing SPEED_SUPER_PLUS constant.
|
||||
</action>
|
||||
<action dev="kayahr" type="add" date="2018-10-08">
|
||||
Wrap new libusb functions: setOption, devMemAlloc, devMemFree.
|
||||
Wrap new libusb functions: setOption, devMemAlloc, devMemFree, interruptEventHandler.
|
||||
</action>
|
||||
<action dev="kayahr" type="update" date="2018-10-07">
|
||||
Updated to libusb 1.0.22.
|
||||
|
|
|
@ -2134,6 +2134,19 @@ public final class LibUsb
|
|||
*/
|
||||
public static native int eventHandlerActive(final Context context);
|
||||
|
||||
/**
|
||||
* Interrupt any active thread that is handling events.
|
||||
*
|
||||
* This is mainly useful for interrupting a dedicated event handling thread when an application wishes to call
|
||||
* {@link #exit()}.
|
||||
*
|
||||
* Since version 1.0.21, LIBUSB_API_VERSION >= 0x01000105
|
||||
*
|
||||
* @param ctx
|
||||
* The context to operate on, or NULL for the default context.
|
||||
*/
|
||||
public static native void interruptEventHandler(final Context context);
|
||||
|
||||
/**
|
||||
* Acquire the event waiters lock.
|
||||
*
|
||||
|
|
|
@ -1098,6 +1098,17 @@ public class LibUsbTest
|
|||
LibUsb.eventHandlerActive(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#interruptEventHandler(Context)} with uninitialized USB context.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testInterruptEventHandlerWithUninitializedContext()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
final Context context = new Context();
|
||||
LibUsb.interruptEventHandler(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#lockEventWaiters(Context)} with uninitialized USB
|
||||
* context.
|
||||
|
@ -1297,4 +1308,16 @@ public class LibUsbTest
|
|||
assertNull(listener.removedFd);
|
||||
assertNull(listener.removedUserData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the {@link LibUsb#interruptEventHandler(Context)} method. Must not crash.
|
||||
*/
|
||||
@Test
|
||||
public void testInterruptEventHandler()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
final Context context = new Context();
|
||||
assertEquals(LibUsb.SUCCESS, LibUsb.init(context));
|
||||
LibUsb.interruptEventHandler(context);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue