Commit da673206 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_object_alive: lock-less and inlined

parent 06e3b333
......@@ -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) )
......
......@@ -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
......
......@@ -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 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment