[vlc-devel] commit: vlc_cancel: POSIX thread cancellation ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Aug 27 22:57:27 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Jul  6 21:10:58 2008 +0300| [779d3cdf33e4d4b014897712fd1e70316fa3c00b] | committer: Rémi Denis-Courmont 

vlc_cancel: POSIX thread cancellation

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=779d3cdf33e4d4b014897712fd1e70316fa3c00b
---

 include/vlc_threads.h |    1 +
 src/libvlccore.sym    |    1 +
 src/misc/threads.c    |   15 +++++++++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 6ce2423..0f25dac 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -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
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 1f5cbd8..f61c17d 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -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
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 41b8b51..6c94811 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -560,6 +560,20 @@ int vlc_clone (vlc_thread_t *p_handle, void * (*entry) (void *), void *data,
 }
 
 /**
+ * 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
  * @param p_result [OUT] pointer to write the thread return value or NULL
@@ -814,3 +828,4 @@ error:
 
     p_priv->b_thread = false;
 }
+




More information about the vlc-devel mailing list