summaryrefslogtreecommitdiff
path: root/libusb/hotplug.c
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-08-12 16:06:38 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2020-08-12 16:06:38 -0700
commitd67eb5beaa44c17c09f089a522ff483f4978a978 (patch)
tree8a5dffe3e6779dc95fa1adb32a1dc6d7be69c7af /libusb/hotplug.c
parentba6b8bcb7ea204e65a3deec3be81aacc9f4b6d5a (diff)
downloadlibusb-d67eb5beaa44c17c09f089a522ff483f4978a978.tar.gz
core: Introduce platform events abstraction
The way in which system handles or resources are represented differs greatly between Unix-like operating systems and Windows. Ever since Windows support was added to libusb, Windows been emulating principles of Unix-like operating systems such as file descriptors and poll(). This commit introduces an abstraction layer that completely removes the need to perform any emulation. Fundamentally there are three things that each platform provides to libusb: 1) A signallable event 2) A timer (not required, but useful) 3) A means to wait for event sources such as the above to be triggered The POSIX abstraction for Unix-like operating systems uses file descriptors as the "handles" to the underlying system resources. The signallable event is implemented using a pipe, the timer as a timerfd (where supported) and the poll() system call is used to wait for events. The Windows abstraction uses native HANDLEs as the "handles" to the underlying system resources. The signallable event is implemented using a manual-reset event, the timer as a manual-reset waitable timer, and the WaitForMultipleObjects() system call is used to wait for events. Closes #252 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/hotplug.c')
-rw-r--r--libusb/hotplug.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libusb/hotplug.c b/libusb/hotplug.c
index c02cc56..86aeed8 100644
--- a/libusb/hotplug.c
+++ b/libusb/hotplug.c
@@ -223,7 +223,7 @@ void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device
pending_events = usbi_pending_events(ctx);
list_add_tail(&message->list, &ctx->hotplug_msgs);
if (!pending_events)
- usbi_signal_event(ctx);
+ usbi_signal_event(&ctx->event);
usbi_mutex_unlock(&ctx->event_data_lock);
}
@@ -347,7 +347,7 @@ void API_EXPORTED libusb_hotplug_deregister_callback(libusb_context *ctx,
pending_events = usbi_pending_events(ctx);
ctx->event_flags |= USBI_EVENT_HOTPLUG_CB_DEREGISTERED;
if (!pending_events)
- usbi_signal_event(ctx);
+ usbi_signal_event(&ctx->event);
usbi_mutex_unlock(&ctx->event_data_lock);
}
}