[vlc-devel] [PATCH] android: remove useless semaphore

Rémi Denis-Courmont remi at remlab.net
Thu Feb 20 11:23:38 CET 2020


I don't know. I put the semaphore in replacement of the atomic variable. Ask Rafaël.

Le 20 février 2020 10:53:32 GMT+02:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>Looks good to me.
>
>Why was there semaphore in the first place ? For cancellation support ?
>
>On Wed, Feb 19, 2020, at 18:29, Rémi Denis-Courmont wrote:
>> pthread_join() already takes care of waiting for the joined thread to
>> terminate.
>> ---
>>  src/android/thread.c | 19 +------------------
>>  1 file changed, 1 insertion(+), 18 deletions(-)
>> 
>> diff --git a/src/android/thread.c b/src/android/thread.c
>> index da128a769c..780183456d 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,13 @@ 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 +213,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 +243,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);
>> -- 
>> 2.25.0
>> 
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200220/a30c7a84/attachment.html>


More information about the vlc-devel mailing list