[vlc-devel] [PATCH] win32: we don't need vlc_WaitForMultipleObjects as we only use single HANDLEs
Steve Lhomme
robux4 at gmail.com
Tue Jul 21 11:31:53 CEST 2015
and the code in vlc_WaitForMultipleObjects was barely common between
the 2 internal calls
---
src/win32/thread.c | 75 ++++++++++++++++++++++++------------------------------
1 file changed, 33 insertions(+), 42 deletions(-)
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 39711b4..890a449 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -49,63 +49,54 @@ static vlc_cond_t super_variable;
static bool isCancelled(void);
#endif
-static DWORD vlc_WaitForMultipleObjects (DWORD count, const HANDLE *handles,
- DWORD delay)
+static DWORD vlc_WaitForSingleObject (HANDLE handle, DWORD delay)
{
DWORD ret;
- if (count == 0)
- {
-#if VLC_WINSTORE_APP
- do {
- DWORD new_delay = 50;
- if (new_delay > delay)
- new_delay = delay;
- ret = SleepEx (new_delay, TRUE);
- if (delay != INFINITE)
- delay -= new_delay;
- if (isCancelled())
- ret = WAIT_IO_COMPLETION;
- } while (delay && ret == 0);
-#else
- ret = SleepEx (delay, TRUE);
-#endif
-
- if (ret == 0)
- ret = WAIT_TIMEOUT;
- }
- else {
#if VLC_WINSTORE_APP
- do {
- DWORD new_delay = 50;
- if (new_delay > delay)
- new_delay = delay;
- ret = WaitForMultipleObjectsEx (count, handles, FALSE, new_delay, TRUE);
- if (delay != INFINITE)
- delay -= new_delay;
- if (isCancelled())
- ret = WAIT_IO_COMPLETION;
- } while (delay && ret == WAIT_TIMEOUT);
+ do {
+ DWORD new_delay = 50;
+ if (new_delay > delay)
+ new_delay = delay;
+ ret = WaitForSingleObjectsEx (handle, FALSE, new_delay, TRUE);
+ if (delay != INFINITE)
+ delay -= new_delay;
+ if (isCancelled())
+ ret = WAIT_IO_COMPLETION;
+ } while (delay && ret == WAIT_TIMEOUT);
#else
- ret = WaitForMultipleObjectsEx (count, handles, FALSE, delay, TRUE);
+ ret = WaitForSingleObjectsEx (count, handle, FALSE, delay, TRUE);
#endif
- }
/* We do not abandon objects... this would be a bug */
- assert (ret < WAIT_ABANDONED_0 || WAIT_ABANDONED_0 + count - 1 < ret);
+ assert(ret != WAIT_ABANDONED_0);
if (unlikely(ret == WAIT_FAILED))
abort (); /* We are screwed! */
return ret;
}
-static DWORD vlc_WaitForSingleObject (HANDLE handle, DWORD delay)
-{
- return vlc_WaitForMultipleObjects (1, &handle, delay);
-}
-
static DWORD vlc_Sleep (DWORD delay)
{
- DWORD ret = vlc_WaitForMultipleObjects (0, NULL, delay);
+ DWORD ret;
+#if VLC_WINSTORE_APP
+ do {
+ DWORD new_delay = 50;
+ if (new_delay > delay)
+ new_delay = delay;
+ ret = SleepEx (new_delay, TRUE);
+ if (delay != INFINITE)
+ delay -= new_delay;
+ if (isCancelled())
+ ret = WAIT_IO_COMPLETION;
+ } while (delay && ret == 0);
+#else
+ ret = SleepEx (delay, TRUE);
+#endif
+
+ if (unlikely(ret == WAIT_FAILED))
+ abort (); /* We are screwed! */
+ if (ret == 0)
+ ret = WAIT_TIMEOUT;
return (ret != WAIT_TIMEOUT) ? ret : 0;
}
--
2.4.2
More information about the vlc-devel
mailing list