]> git.sesse.net Git - vlc/blobdiff - src/misc/threads.c
vlc_cancel: POSIX thread cancellation
[vlc] / src / misc / threads.c
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;
 }
+