[vlc-commits] picture_pool: relax memory order

Rémi Denis-Courmont git at videolan.org
Sun Jul 1 11:22:11 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul  1 12:20:34 2018 +0300| [ae2fed77b4833d522087176048d2586c60f9bd9b] | committer: Rémi Denis-Courmont

picture_pool: relax memory order

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

 src/misc/picture_pool.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
index 74712c81f5..874a04e4d8 100644
--- a/src/misc/picture_pool.c
+++ b/src/misc/picture_pool.c
@@ -53,9 +53,10 @@ struct picture_pool_t {
 
 static void picture_pool_Destroy(picture_pool_t *pool)
 {
-    if (atomic_fetch_sub(&pool->refs, 1) != 1)
+    if (atomic_fetch_sub_explicit(&pool->refs, 1, memory_order_release) != 1)
         return;
 
+    atomic_thread_fence(memory_order_acquire);
     vlc_cond_destroy(&pool->wait);
     vlc_mutex_destroy(&pool->lock);
     aligned_free(pool);
@@ -231,7 +232,7 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
         picture_t *clone = picture_pool_ClonePicture(pool, i);
         if (clone != NULL) {
             assert(clone->p_next == NULL);
-            atomic_fetch_add(&pool->refs, 1);
+            atomic_fetch_add_explicit(&pool->refs, 1, memory_order_relaxed);
         }
         return clone;
     }
@@ -272,7 +273,7 @@ picture_t *picture_pool_Wait(picture_pool_t *pool)
     picture_t *clone = picture_pool_ClonePicture(pool, i);
     if (clone != NULL) {
         assert(clone->p_next == NULL);
-        atomic_fetch_add(&pool->refs, 1);
+        atomic_fetch_add_explicit(&pool->refs, 1, memory_order_relaxed);
     }
     return clone;
 }



More information about the vlc-commits mailing list