]> git.sesse.net Git - vlc/commitdiff
vlc_cancel: POSIX thread cancellation
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 6 Jul 2008 18:10:58 +0000 (21:10 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 27 Aug 2008 19:43:03 +0000 (22:43 +0300)
include/vlc_threads.h
src/libvlccore.sym
src/misc/threads.c

index 6ce24237ae4569f285ee57a0ef4659caea14b5fc..0f25dacd6caa7f7cb30e1d275f281d56e11de13e 100644 (file)
@@ -177,6 +177,7 @@ VLC_EXPORT( int,  __vlc_thread_set_priority, ( vlc_object_t *, const char *, int
 VLC_EXPORT( void, __vlc_thread_join,   ( vlc_object_t *, const char *, int ) );
 
 VLC_EXPORT( int, vlc_clone, (vlc_thread_t *, void * (*) (void *), void *, int) );
+VLC_EXPORT( void, vlc_cancel, (vlc_thread_t) );
 VLC_EXPORT( int, vlc_join, (vlc_thread_t, void **) );
 
 #define vlc_thread_ready vlc_object_signal
index 1f5cbd8107bbef9e37a4d19781bb0cb2cfbbcffa..f61c17d6c6a34c6011b04ca01b4fdc9fd3dbfd10 100644 (file)
@@ -415,6 +415,7 @@ vlc_b64_decode_binary
 vlc_b64_decode_binary_to_buffer
 vlc_b64_encode
 vlc_b64_encode_binary
+vlc_cancel
 VLC_Changeset
 vlc_clone
 VLC_CompileBy
index 41b8b51cb825d1f5910a2fdb51043d014f649ac9..6c94811e32b6127c31327c36bc35c43f73cb90c0 100644 (file)
@@ -559,6 +559,20 @@ int vlc_clone (vlc_thread_t *p_handle, void * (*entry) (void *), void *data,
     return ret;
 }
 
+/**
+ * Marks a thread as cancelled. Next time the target thread reaches a
+ * cancellation point (while not having disabled cancellation), it will
+ * run its cancellation cleanup handler, the thread variable destructors, and
+ * terminate. vlc_join() must be used afterward regardless of a thread being
+ * cancelled or not.
+ */
+void vlc_cancel (vlc_thread_t thread_id)
+{
+#if defined (LIBVLC_USE_PTHREAD)
+    pthread_cancel (thread_id);
+#endif
+}
+
 /**
  * Waits for a thread to complete (if needed), and destroys it.
  * @param handle thread handle
@@ -814,3 +828,4 @@ error:
 
     p_priv->b_thread = false;
 }
+