]> git.sesse.net Git - vlc/commitdiff
Following vlc_object_kill(), add vlc_object_dying()
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 19 May 2007 18:56:22 +0000 (18:56 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 19 May 2007 18:56:22 +0000 (18:56 +0000)
include/vlc_objects.h
include/vlc_threads_funcs.h
src/misc/objects.c

index 88a6f4dd224a6ea49ff5e9333a064bebedf3fa82..f12c070939444823416e670e469b13c51d522e54 100644 (file)
@@ -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 ) );
index c81713689fc0bb99f878d2f19ed6e2f6bd5fbd2a..269287b69c3c980805773ee708cc6237ad93802c 100644 (file)
@@ -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
  *****************************************************************************/
index 4e2ef8812819a97fca61f3db5d4277b60f6e3643..cde9aa2f8ddbe3a30f97c9420f2c6e9fba1639f8 100644 (file)
@@ -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
  *