From 8fd6167afd8a01b05a1564f8e8f807db786d1e8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 19 May 2007 18:56:22 +0000 Subject: [PATCH] Following vlc_object_kill(), add vlc_object_dying() --- include/vlc_objects.h | 2 ++ include/vlc_threads_funcs.h | 7 +++++++ src/misc/objects.c | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/include/vlc_objects.h b/include/vlc_objects.h index 88a6f4dd22..f12c070939 100644 --- a/include/vlc_objects.h +++ b/include/vlc_objects.h @@ -97,6 +97,8 @@ struct vlc_object_t VLC_EXPORT( void *, __vlc_object_create, ( vlc_object_t *, int ) ); VLC_EXPORT( void, __vlc_object_destroy, ( vlc_object_t * ) ); VLC_EXPORT( void, __vlc_object_kill, ( vlc_object_t * ) ); +VLC_EXPORT( vlc_bool_t, __vlc_object_dying_unlocked, ( vlc_object_t * ) ); +VLC_EXPORT( vlc_bool_t, __vlc_object_dying, ( vlc_object_t * ) ); VLC_EXPORT( void, __vlc_object_attach, ( vlc_object_t *, vlc_object_t * ) ); VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) ); VLC_EXPORT( void *, __vlc_object_get, ( vlc_object_t *, int ) ); diff --git a/include/vlc_threads_funcs.h b/include/vlc_threads_funcs.h index c81713689f..269287b69c 100644 --- a/include/vlc_threads_funcs.h +++ b/include/vlc_threads_funcs.h @@ -122,6 +122,9 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line, } #elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) +# define vlc_assert_locked( m ) \ + assert (pthread_mutex_lock (&((m)->mutex)) == EDEADLK) + i_result = pthread_mutex_lock( &p_mutex->mutex ); if ( i_result ) { @@ -144,6 +147,10 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line, return i_result; } +#ifndef vlc_assert_locked +# define vlc_assert_locked( m ) (void)0 +#endif + /***************************************************************************** * vlc_mutex_unlock: unlock a mutex *****************************************************************************/ diff --git a/src/misc/objects.c b/src/misc/objects.c index 4e2ef88128..cde9aa2f8d 100644 --- a/src/misc/objects.c +++ b/src/misc/objects.c @@ -438,6 +438,23 @@ void __vlc_object_kill( vlc_object_t *p_this ) } +vlc_bool_t __vlc_object_dying_unlocked( vlc_object_t *p_this ) +{ + vlc_assert_locked( &p_this->object_lock ); + return p_this->b_die; +} + + +vlc_bool_t __vlc_object_dying( vlc_object_t *p_this ) +{ + vlc_bool_t b; + vlc_mutex_lock( &p_this->object_lock ); + b = __vlc_object_dying_unlocked( p_this ); + vlc_mutex_unlock( &p_this->object_lock ); + return b; +} + + /** * find an object given its ID * -- 2.39.2