]> git.sesse.net Git - vlc/commitdiff
vlc_object_alive: lock-less and inlined
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 5 Jul 2008 11:22:09 +0000 (14:22 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 5 Jul 2008 11:22:09 +0000 (14:22 +0300)
include/vlc_objects.h
src/libvlccore.sym
src/misc/objects.c

index a027dd9b345dbd0ff99aba2ed569d99c226b4d3e..c3b207880a3c55a6c0fb9f0b4d167592ed388515 100644 (file)
@@ -162,7 +162,12 @@ VLC_EXPORT( void, __vlc_object_kill, ( vlc_object_t * ) );
 #define vlc_object_kill(a) \
     __vlc_object_kill( VLC_OBJECT(a) )
 
-VLC_EXPORT( bool, __vlc_object_alive, ( vlc_object_t * ) );
+static inline bool __vlc_object_alive (vlc_object_t *obj)
+{
+    barrier ();
+    return !obj->b_die;
+}
+
 #define vlc_object_alive(a) \
     __vlc_object_alive( VLC_OBJECT(a) )
 
index 698bd850dc2c871499ff75ffe27f8da69d61a182..68438ae157999ebda2a7c42eb9bbdf12982ce9fb 100644 (file)
@@ -433,7 +433,6 @@ vlc_module_set
 __vlc_mutex_destroy
 vlc_mutex_init
 vlc_mutex_init_recursive
-__vlc_object_alive
 __vlc_object_attach
 __vlc_object_create
 __vlc_object_detach
index 74564e3eb90b22effd5d79637e46b7cf35306861..7e8e7ef93818988ff91a06829a96009558b8363f 100644 (file)
@@ -546,35 +546,6 @@ int __vlc_object_timedwait( vlc_object_t *obj, mtime_t deadline )
 }
 
 
-/**
- * Checks whether an object has been "killed".
- * The object lock must be held.
- *
- * Typical code for an object thread could be:
- *
-   vlc_object_lock (self);
-   ...initialization...
-   while (vlc_object_alive (self))
-   {
-       ...preprocessing...
-
-       vlc_object_wait (self);
-
-       ...postprocessing...
-   }
-   ...deinitialization...
-   vlc_object_unlock (self);
- *
- *
- * @return true iff the object has not been killed yet
- */
-bool __vlc_object_alive( vlc_object_t *obj )
-{
-    vlc_assert_locked( &(vlc_internals(obj)->lock) );
-    return !obj->b_die;
-}
-
-
 /**
  * Signals an object for which the lock is held.
  * At least one thread currently sleeping in vlc_object_wait() or
@@ -613,6 +584,7 @@ void __vlc_object_kill( vlc_object_t *p_this )
     }
 
     vlc_object_signal_unlocked( p_this );
+    /* This also serves as a memory barrier toward vlc_object_alive(): */
     vlc_object_unlock( p_this );
 }