[vlc-commits] vlc_timer_*: use atomic_*() functions

Rémi Denis-Courmont git at videolan.org
Fri May 11 21:41:03 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri May 11 22:39:23 2012 +0300| [63d5e98ccde785943401e06f09abf0152e59a8f6] | committer: Rémi Denis-Courmont

vlc_timer_*: use atomic_*() functions

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

 src/posix/thread.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/posix/thread.c b/src/posix/thread.c
index a7a4873..138eac1 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -994,7 +994,7 @@ struct vlc_timer
     void       (*func) (void *);
     void        *data;
     mtime_t      value, interval;
-    vlc_atomic_t overruns;
+    atomic_uint  overruns;
 };
 
 VLC_NORETURN
@@ -1037,7 +1037,8 @@ static void *vlc_timer_thread (void *data)
         {
             misses--;
             timer->value += misses * timer->interval;
-            vlc_atomic_add (&timer->overruns, misses);
+            atomic_fetch_add_explicit (&timer->overruns, misses,
+                                       memory_order_relaxed);
         }
     }
 
@@ -1069,7 +1070,7 @@ int vlc_timer_create (vlc_timer_t *id, void (*func) (void *), void *data)
     timer->data = data;
     timer->value = 0;
     timer->interval = 0;
-    vlc_atomic_set(&timer->overruns, 0);
+    atomic_init(&timer->overruns, 0);
 
     if (vlc_clone (&timer->thread, vlc_timer_thread, timer,
                    VLC_THREAD_PRIORITY_INPUT))
@@ -1141,7 +1142,8 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
  */
 unsigned vlc_timer_getoverrun (vlc_timer_t timer)
 {
-    return vlc_atomic_swap (&timer->overruns, 0);
+    return atomic_exchange_explicit (&timer->overruns, 0,
+                                     memory_order_relaxed);
 }
 
 



More information about the vlc-commits mailing list