[vlc-commits] background_thread: add a new cond

Thomas Guillem git at videolan.org
Mon Oct 9 09:53:10 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Oct  6 18:10:39 2017 +0200| [953219982aa3ca7e8ec9ec8d7c0c776f50e6e6d6] | committer: Thomas Guillem

background_thread: add a new cond

For clients -> worker signals.

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

 src/misc/background_worker.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/misc/background_worker.c b/src/misc/background_worker.c
index a3dd825f1a..70902e5b64 100644
--- a/src/misc/background_worker.c
+++ b/src/misc/background_worker.c
@@ -41,6 +41,7 @@ struct background_worker {
     struct {
         bool probe_request; /**< true if a probe is requested */
         vlc_cond_t wait; /**< wait for update in terms of head */
+        vlc_cond_t worker_wait; /**< wait for probe request or cancelation */
         mtime_t deadline; /**< deadline of the current task */
         void* id; /**< id of the current task */
         bool active; /**< true if there is an active thread */
@@ -112,7 +113,7 @@ static void* Thread( void* data )
             if( worker->head.probe_request == false &&
                 worker->head.deadline > mdate() )
             {
-                vlc_cond_timedwait( &worker->head.wait, &worker->lock,
+                vlc_cond_timedwait( &worker->head.worker_wait, &worker->lock,
                                      worker->head.deadline );
             }
             vlc_mutex_unlock( &worker->lock );
@@ -145,7 +146,7 @@ static void BackgroundWorkerCancel( struct background_worker* worker, void* id)
         || ( id != NULL && worker->head.id == id ) )
     {
         worker->head.deadline = VLC_TS_0;
-        vlc_cond_broadcast( &worker->head.wait );
+        vlc_cond_signal( &worker->head.worker_wait );
         vlc_cond_wait( &worker->head.wait, &worker->lock );
     }
     vlc_mutex_unlock( &worker->lock );
@@ -167,6 +168,7 @@ struct background_worker* background_worker_New( void* owner,
 
     vlc_mutex_init( &worker->lock );
     vlc_cond_init( &worker->head.wait );
+    vlc_cond_init( &worker->head.worker_wait );
 
     vlc_array_init( &worker->tail.data );
 
@@ -213,7 +215,7 @@ void background_worker_RequestProbe( struct background_worker* worker )
 {
     vlc_mutex_lock( &worker->lock );
     worker->head.probe_request = true;
-    vlc_cond_broadcast( &worker->head.wait );
+    vlc_cond_signal( &worker->head.worker_wait );
     vlc_mutex_unlock( &worker->lock );
 }
 
@@ -223,5 +225,6 @@ void background_worker_Delete( struct background_worker* worker )
     vlc_array_clear( &worker->tail.data );
     vlc_mutex_destroy( &worker->lock );
     vlc_cond_destroy( &worker->head.wait );
+    vlc_cond_destroy( &worker->head.worker_wait );
     free( worker );
 }



More information about the vlc-commits mailing list