[vlc-commits] commit: vlc_clone_detach: remove thread handle parameter ( =?UTF-8?Q?R=C3=A9mi=20Denis=2DCourmont=20?=)

git at videolan.org git at videolan.org
Sat Dec 4 18:23:41 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec  4 18:55:46 2010 +0200| [653a66372d98131ab4c3f86bbf1d4786222d4c4c] | committer: Rémi Denis-Courmont 

vlc_clone_detach: remove thread handle parameter

This made no sense. If the thread is detached, the handle is released
asynchronously when the thread exits. So it cannot be used in any way
(except from the thread itself).

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

 src/libvlc.h             |    2 +-
 src/misc/pthread.c       |   14 ++++----------
 src/playlist/fetcher.c   |    3 +--
 src/playlist/preparser.c |    3 +--
 src/win32/thread.c       |   10 +++-------
 5 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/src/libvlc.h b/src/libvlc.h
index 82a05d0..abbc1ac 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -52,7 +52,7 @@ void system_End       ( libvlc_int_t * );
  */
 
 /* This cannot be used as is from plugins yet: */
-int vlc_clone_detach (vlc_thread_t *, void *(*)(void *), void *, int);
+int vlc_clone_detach (void *(*)(void *), void *, int);
 
 /* Hopefully, no need to export this. There is a new thread API instead. */
 void vlc_thread_cancel (vlc_object_t *);
diff --git a/src/misc/pthread.c b/src/misc/pthread.c
index 6512c2e..abf1c9f 100644
--- a/src/misc/pthread.c
+++ b/src/misc/pthread.c
@@ -717,8 +717,7 @@ void vlc_join (vlc_thread_t handle, void **result)
  * Creates and starts new detached thread.
  * A detached thread cannot be joined. Its resources will be automatically
  * released whenever the thread exits (in particular, its call stack will be
- * reclaimed). Nevertheless, a detached thread may
- * be cancelled; this can expedite its termination.
+ * reclaimed).
  *
  * Detached thread are particularly useful when some work needs to be done
  * asynchronously, that is likely to be completed much earlier than the thread
@@ -731,24 +730,19 @@ void vlc_join (vlc_thread_t handle, void **result)
  * thread. In practice, LibVLC will wait for detached threads to exit before
  * it unloads the plugins.
  *
- * @param th [OUT] pointer to hold the thread handle, or NULL
  * @param entry entry point for the thread
  * @param data data parameter given to the entry point
  * @param priority thread priority value
  * @return 0 on success, a standard error code on error.
  */
-int vlc_clone_detach (vlc_thread_t *th, void *(*entry) (void *), void *data,
-                      int priority)
+int vlc_clone_detach (void *(*entry) (void *), void *data, int priority)
 {
-    vlc_thread_t dummy;
+    vlc_thread_t th;
     pthread_attr_t attr;
 
-    if (th == NULL)
-        th = &dummy;
-
     pthread_attr_init (&attr);
     pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
-    return vlc_clone_attr (th, &attr, entry, data, priority);
+    return vlc_clone_attr (&th, &attr, entry, data, priority);
 }
 
 /**
diff --git a/src/playlist/fetcher.c b/src/playlist/fetcher.c
index 2113d42..00f1137 100644
--- a/src/playlist/fetcher.c
+++ b/src/playlist/fetcher.c
@@ -91,8 +91,7 @@ void playlist_fetcher_Push( playlist_fetcher_t *p_fetcher,
                  p_fetcher->i_waiting, p_item );
     if( !p_fetcher->b_live )
     {
-        if( vlc_clone_detach( NULL, Thread, p_fetcher,
-                              VLC_THREAD_PRIORITY_LOW ) )
+        if( vlc_clone_detach( Thread, p_fetcher, VLC_THREAD_PRIORITY_LOW ) )
             msg_Err( p_fetcher->p_playlist,
                      "cannot spawn secondary preparse thread" );
         else
diff --git a/src/playlist/preparser.c b/src/playlist/preparser.c
index dfd955a..d2bf99f 100644
--- a/src/playlist/preparser.c
+++ b/src/playlist/preparser.c
@@ -83,8 +83,7 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p
                  p_preparser->i_waiting, p_item );
     if( !p_preparser->b_live )
     {
-        if( vlc_clone_detach( NULL, Thread, p_preparser,
-                              VLC_THREAD_PRIORITY_LOW ) )
+        if( vlc_clone_detach( Thread, p_preparser, VLC_THREAD_PRIORITY_LOW ) )
             msg_Warn( p_preparser->p_playlist,
                       "cannot spawn pre-parser thread" );
         else
diff --git a/src/win32/thread.c b/src/win32/thread.c
index ddbee72..cd607ec 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -625,19 +625,15 @@ void vlc_join (vlc_thread_t th, void **result)
 #endif
 }
 
-int vlc_clone_detach (vlc_thread_t *p_handle, void *(*entry) (void *),
-                      void *data, int priority)
+int vlc_clone_detach (void *(*entry) (void *), void *data, int priority)
 {
     vlc_thread_t th;
-    if (p_handle == NULL)
-        p_handle = &th;
-
-    int ret = vlc_clone (p_handle, entry, data, priority);
+    int ret = vlc_clone (&th, entry, data, priority);
     if (ret)
         return ret;
 
     /* FIXME: handle->cancel_event leak UNDER_CE */
-    CloseHandle ((*p_handle)->id);
+    CloseHandle (th->id);
     return 0;
 }
 



More information about the vlc-commits mailing list