[vlc-commits] android: remove useless semaphore

Rémi Denis-Courmont git at videolan.org
Thu Feb 20 19:48:28 CET 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Feb 19 19:26:49 2020 +0200| [0d0fd05b6e9daa2cceefe5becc4e94a4026ccac4] | committer: Rémi Denis-Courmont

android: remove useless semaphore

pthread_join() already takes care of waiting for the joined thread to
terminate.

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

 src/android/thread.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/src/android/thread.c b/src/android/thread.c
index da128a769c..fd5be51965 100644
--- a/src/android/thread.c
+++ b/src/android/thread.c
@@ -133,7 +133,6 @@ void vlc_once(vlc_once_t *once, void (*cb)(void))
 struct vlc_thread
 {
     pthread_t      thread;
-    vlc_sem_t      finished;
 
     void *(*entry)(void*);
     void *data;
@@ -183,25 +182,12 @@ static void *detached_thread(void *data)
     return NULL;
 }
 
-static void finish_joinable_thread(void *data)
-{
-    vlc_thread_t th = data;
-
-    vlc_sem_post(&th->finished);
-}
-
 static void *joinable_thread(void *data)
 {
     vlc_thread_t th = data;
-    void *ret;
 
-    vlc_cleanup_push(finish_joinable_thread, th);
     thread = th;
-    ret = th->entry(th->data);
-    vlc_cleanup_pop();
-    vlc_sem_post(&th->finished);
-
-    return ret;
+    return th->entry(th->data);
 }
 
 static int vlc_clone_attr (vlc_thread_t *th, void *(*entry) (void *),
@@ -226,8 +212,6 @@ static int vlc_clone_attr (vlc_thread_t *th, void *(*entry) (void *),
         pthread_sigmask (SIG_BLOCK, &set, &oldset);
     }
 
-    if (!detach)
-        vlc_sem_init(&thread->finished, 0);
     atomic_store(&thread->killed, false);
     thread->killable = true;
     thread->entry = entry;
@@ -258,8 +242,6 @@ int vlc_clone (vlc_thread_t *th, void *(*entry) (void *), void *data,
 
 void vlc_join (vlc_thread_t handle, void **result)
 {
-    vlc_sem_wait (&handle->finished);
-
     int val = pthread_join (handle->thread, result);
     VLC_THREAD_ASSERT ("joining thread");
     clean_detached_thread(handle);



More information about the vlc-commits mailing list