[vlc-devel] commit: vlc_savecancel, vlc_restorecancel: POSIX cancellation state management ( Rémi Denis-Courmont )

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


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Jul  6 20:55:17 2008 +0300| [a332d4e1f1f833e14209989ff51009c85ea2012c] | committer: Rémi Denis-Courmont 

vlc_savecancel, vlc_restorecancel: POSIX cancellation state management

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

 include/vlc_threads.h |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 748f15e..6ce2423 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -3,7 +3,7 @@
  * This header provides portable declarations for mutexes & conditions
  *****************************************************************************
  * Copyright (C) 1999, 2002 the VideoLAN team
- * $Id$
+ * Copyright © 2007-2008 Rémi Denis-Courmont
  *
  * Authors: Jean-Marc Dressler <polux at via.ecp.fr>
  *          Samuel Hocevar <sam at via.ecp.fr>
@@ -588,6 +588,32 @@ static inline void barrier (void)
 #endif
 }
 
+/**
+ * Save the cancellation state and disable cancellation for the calling thread.
+ * This function must be called before entering a piece of code that is not
+ * cancellation-safe.
+ * @param p_state storage for the previous cancellation state
+ * @return Nothing, always succeeds.
+ */
+static inline void vlc_savecancel (int *p_state)
+{
+#if defined (LIBVLC_USE_PTHREAD)
+    (void) pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, p_state);
+#endif
+}
+
+/**
+ * Restore the cancellation state for the calling thread.
+ * @param state previous state as returned by vlc_savecancel().
+ * @return Nothing, always succeeds.
+ */
+static inline void vlc_restorecancel (int state)
+{
+#if defined (LIBVLC_USE_PTHREAD)
+    (void) pthread_setcancelstate (state, NULL);
+#endif
+}
+
 /*****************************************************************************
  * vlc_thread_create: create a thread
  *****************************************************************************/




More information about the vlc-devel mailing list