[x264-devel] [PATCH] This change moves the read of pool->exit to within mutex scope. Writes to the variable are already within mutex scope.

Daniel Deptford ddeptford at google.com
Tue Dec 11 14:47:05 CET 2018


---
 common/threadpool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/threadpool.c b/common/threadpool.c
index 7f98f778..80b0f99b 100644
--- a/common/threadpool.c
+++ b/common/threadpool.c
@@ -52,7 +52,8 @@ static void *threadpool_thread_internal( x264_threadpool_t *pool )
     if( pool->init_func )
         pool->init_func( pool->init_arg );
 
-    while( !pool->exit )
+    int exit = 0;
+    while( !exit )
     {
         x264_threadpool_job_t *job = NULL;
         x264_pthread_mutex_lock( &pool->run.mutex );
@@ -63,6 +64,7 @@ static void *threadpool_thread_internal( x264_threadpool_t *pool )
             job = (void*)x264_frame_shift( pool->run.list );
             pool->run.i_size--;
         }
+        exit = pool->exit;
         x264_pthread_mutex_unlock( &pool->run.mutex );
         if( !job )
             continue;
-- 
2.20.0.rc2.403.gdbc3b29805-goog



More information about the x264-devel mailing list