Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions libusb/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,16 +1215,16 @@ static void* callback_thread(void* user_data)
{
(void) user_data;

/* 5 msec timeout seems reasonable; don't set too low to avoid high CPU usage */
/* This timeout only affects how much time it takes to stop the thread */
hidapi_timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 5000000;

hidapi_thread_mutex_lock(&hid_hotplug_context.callback_thread);

/* We stop the thread if by the moment there are no events left in the queue there are no callbacks left */
while (1) {
/* 5 msec timeout seems reasonable; don't set too low to avoid high CPU usage */
/* This timeout only affects how much time it takes to stop the thread */
hidapi_timespec ts;
hidapi_thread_gettime(&ts);
hidapi_thread_addtime(&ts, 5);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd set it to 1 second - I've been using 1 second in multiple projects, and seems reasonable
5 second to exit the thread (effectively - to quit the application in some cases) seem a bit too much


/* Make the tread fall asleep and wait for a condition to wake it up */
hidapi_thread_cond_timedwait(&hid_hotplug_context.callback_thread, &ts);

Expand Down
Loading