Windows: Improve locking in threading abstraction
authorChris Dickens <christopher.a.dickens@gmail.com>
Thu, 4 Jan 2018 05:18:02 +0000 (21:18 -0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Thu, 4 Jan 2018 07:24:27 +0000 (23:24 -0800)
commit4be320236ec485dd32ada1b85d4c0551274d1f8a
treefddb9d2d5e6fa1e18d4ebdfdf5a0b6b684c97dfd
parent3001f934776c5bb61a735fe676c3d82e69c47868
Windows: Improve locking in threading abstraction

Convert the usbi_mutex_t type to a CRITICAL_SECTION object. There
are numerous advantages including lower resource usage and a better
fast-path (doesn't require entering kernel space).

Simplify the condition variable implementation by not associating a
wait structure with a particular thread ID. This is not needed and
causes an unnecessary search through the linked list of any available
wait structures when the real optimization is just reusing an already
created event object.

Also, while here remove all the checks for NULL pointers because we
don't do such a silly thing inside the library.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/threads_windows.c
libusb/os/threads_windows.h
libusb/os/windows_nt_common.c
libusb/version_nano.h