Commit 653a6637 authored by Rémi Denis-Courmont's avatar 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).
parent 0bb330fd
......@@ -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 *);
......
......@@ -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);
}
/**
......
......@@ -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
......
......@@ -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
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment