[vlc-commits] win32: thread: remove unused detached thread support

Steve Lhomme git at videolan.org
Mon Nov 9 15:27:55 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Nov  9 13:04:49 2020 +0100| [8675f083e7d4952383a452f9ca9d060071b42ddd] | committer: Steve Lhomme

win32: thread: remove unused detached thread support

Following a10ac09d42601cdf0671a58f5f971e7665e7e8d6

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8675f083e7d4952383a452f9ca9d060071b42ddd
---

 src/win32/thread.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/src/win32/thread.c b/src/win32/thread.c
index 3879b46388..60b4232e04 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -339,12 +339,6 @@ void vlc_atomic_notify_all(void *addr)
 }
 
 /*** Threads ***/
-static void vlc_thread_destroy(vlc_thread_t th)
-{
-    DeleteCriticalSection(&th->wait.lock);
-    free(th);
-}
-
 static
 #if VLC_WINSTORE_APP
 DWORD
@@ -360,13 +354,11 @@ __stdcall vlc_entry (void *p)
     th->data = th->entry (th->data);
     TlsSetValue(thread_key, NULL);
 
-    if (th->id == NULL) /* Detached thread */
-        vlc_thread_destroy(th);
     return 0;
 }
 
-static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached,
-                           void *(*entry) (void *), void *data, int priority)
+int vlc_clone (vlc_thread_t *p_handle, void *(*entry) (void *),
+               void *data, int priority)
 {
     struct vlc_thread *th = malloc (sizeof (*th));
     if (unlikely(th == NULL))
@@ -396,13 +388,7 @@ static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached,
         return err;
     }
 
-    if (detached)
-    {
-        CloseHandle(h);
-        th->id = NULL;
-    }
-    else
-        th->id = h;
+    th->id = h;
 
     if (p_handle != NULL)
         *p_handle = th;
@@ -413,12 +399,6 @@ static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached,
     return 0;
 }
 
-int vlc_clone (vlc_thread_t *p_handle, void *(*entry) (void *),
-                void *data, int priority)
-{
-    return vlc_clone_attr (p_handle, false, entry, data, priority);
-}
-
 void vlc_join (vlc_thread_t th, void **result)
 {
     DWORD ret;
@@ -433,7 +413,8 @@ void vlc_join (vlc_thread_t th, void **result)
     if (result != NULL)
         *result = th->data;
     CloseHandle (th->id);
-    vlc_thread_destroy(th);
+    DeleteCriticalSection(&th->wait.lock);
+    free(th);
 }
 
 unsigned long vlc_thread_id (void)
@@ -514,8 +495,6 @@ void vlc_testcancel (void)
         p->proc (p->data);
 
     th->data = NULL; /* TODO: special value? */
-    if (th->id == NULL) /* Detached thread */
-        vlc_thread_destroy(th);
 #if VLC_WINSTORE_APP
     ExitThread(0);
 #else // !VLC_WINSTORE_APP



More information about the vlc-commits mailing list