[vlc-commits] [Git][videolan/vlc][master] 4 commits: win32: thread: keep using a bool for the killable flag
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Aug 12 05:41:50 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
8e7a66b5 by Steve Lhomme at 2022-08-12T05:23:59+00:00
win32: thread: keep using a bool for the killable flag
No need for any conversion to int internally.
- - - - -
f7151490 by Steve Lhomme at 2022-08-12T05:23:59+00:00
win32: thread: don't check canceletation without a vlc_thread
None of this code block works if th is NULL (external thread), as there is no
"killed" variable.
- - - - -
dcebc092 by Steve Lhomme at 2022-08-12T05:23:59+00:00
win32: thread: use kernelbase.dll to get the thread name API
This is what the documentation [1] says we should use.
Kernel32.dll is just redirecting to api-ms-win-core-processthreads-l1-1-3.dll
but kernelbase.dll is not a redirection.
[1] https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
- - - - -
03937b92 by Steve Lhomme at 2022-08-12T05:23:59+00:00
win32: thread: apply the vlc_testcancel() code in local calls
And then simplify the code locally.
Now there's only one current_thread_ctx TLS lookup for the whole duration of
vlc_tick_wait().
The killed variable is only check if it's a VLC thread and killable is true.
Not sure why the Win8+ code differs from the rest, even the memory order
loading of th->killed is different.
- - - - -
1 changed file:
- src/win32/thread.c
Changes:
=====================================
src/win32/thread.c
=====================================
@@ -443,7 +443,7 @@ int vlc_savecancel (void)
if (th == NULL)
return false; /* Main thread - cannot be cancelled anyway */
- int state = th->killable;
+ bool state = th->killable;
th->killable = false;
return state;
}
@@ -457,7 +457,7 @@ void vlc_restorecancel (int state)
return; /* Main thread - cannot be cancelled anyway */
assert (!th->killable);
- th->killable = state != 0;
+ th->killable = !!state;
}
noreturn static void vlc_docancel(struct vlc_thread *th)
@@ -591,11 +591,10 @@ vlc_tick_t vlc_tick_now (void)
void (vlc_tick_wait)(vlc_tick_t deadline)
{
vlc_tick_t delay;
-#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
struct vlc_thread *th = current_thread_ctx;
-
- if (th != NULL && th->killable)
+ if (likely(th != NULL) && th->killable)
{
+#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
do
{
if (atomic_load_explicit(&th->killed, memory_order_acquire))
@@ -604,10 +603,11 @@ void (vlc_tick_wait)(vlc_tick_t deadline)
while (vlc_atomic_timedwait(&th->killed, false, deadline) == 0);
return;
- }
#else
- vlc_testcancel();
+ if (atomic_load_explicit(&th->killed, memory_order_relaxed))
+ vlc_docancel(th);
#endif
+ }
while ((delay = (deadline - vlc_tick_now())) > 0)
{
@@ -619,7 +619,12 @@ void (vlc_tick_wait)(vlc_tick_t deadline)
Sleep(delay);
#else
SleepEx(delay, TRUE);
- vlc_testcancel();
+
+ if (likely(th != NULL) && th->killable)
+ {
+ if (atomic_load_explicit(&th->killed, memory_order_relaxed))
+ vlc_docancel(th);
+ }
#endif
}
}
@@ -716,7 +721,7 @@ BOOL WINAPI DllMain (HANDLE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
case DLL_PROCESS_ATTACH:
{
HMODULE h;
- h = GetModuleHandle(TEXT("kernel32.dll"));
+ h = GetModuleHandle(TEXT("kernelbase.dll"));
if (h == NULL)
h = GetModuleHandle(TEXT("api-ms-win-core-processthreads-l1-1-3.dll"));
if (h != NULL)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/47aaf6afd174324cc2935a23d4066c8e25e02162...03937b92c3dc837a65c31dc98193b62ffd4dd1ec
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/47aaf6afd174324cc2935a23d4066c8e25e02162...03937b92c3dc837a65c31dc98193b62ffd4dd1ec
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list