Commit 757e6a6e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Revert "vlc_clone_detach: remove thread handle parameter"

This reverts commit 653a6637.

Conflicts:

	src/win32/thread.c
parent c97e1959
......@@ -52,7 +52,7 @@ void system_End ( libvlc_int_t * );
*/
/* This cannot be used as is from plugins yet: */
int vlc_clone_detach (void *(*)(void *), void *, int);
int vlc_clone_detach (vlc_thread_t *, 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,7 +717,8 @@ 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).
* reclaimed). Nevertheless, a detached thread may
* be cancelled; this can expedite its termination.
*
* Detached thread are particularly useful when some work needs to be done
* asynchronously, that is likely to be completed much earlier than the thread
......@@ -730,19 +731,24 @@ 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 (void *(*entry) (void *), void *data, int priority)
int vlc_clone_detach (vlc_thread_t *th, void *(*entry) (void *), void *data,
int priority)
{
vlc_thread_t th;
vlc_thread_t dummy;
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,7 +91,8 @@ void playlist_fetcher_Push( playlist_fetcher_t *p_fetcher,
p_fetcher->i_waiting, p_item );
if( !p_fetcher->b_live )
{
if( vlc_clone_detach( Thread, p_fetcher, VLC_THREAD_PRIORITY_LOW ) )
if( vlc_clone_detach( NULL, Thread, p_fetcher,
VLC_THREAD_PRIORITY_LOW ) )
msg_Err( p_fetcher->p_playlist,
"cannot spawn secondary preparse thread" );
else
......
......@@ -83,7 +83,8 @@ 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( Thread, p_preparser, VLC_THREAD_PRIORITY_LOW ) )
if( vlc_clone_detach( NULL, Thread, p_preparser,
VLC_THREAD_PRIORITY_LOW ) )
msg_Warn( p_preparser->p_playlist,
"cannot spawn pre-parser thread" );
else
......
......@@ -563,15 +563,15 @@ static unsigned __stdcall vlc_entry (void *p)
return 0;
}
int vlc_clone (vlc_thread_t *p_handle, void * (*entry) (void *), void *data,
int priority)
static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached,
void *(*entry) (void *), void *data, int priority)
{
struct vlc_thread *th = malloc (sizeof (*th));
if (unlikely(th == NULL))
return ENOMEM;
th->entry = entry;
th->data = data;
th->detached = p_handle == NULL;
th->detached = detached;
th->killable = false; /* not until vlc_entry() ! */
th->killed = false;
th->cleaners = NULL;
......@@ -623,6 +623,12 @@ int vlc_clone (vlc_thread_t *p_handle, void * (*entry) (void *), void *data,
return 0;
}
int vlc_clone (vlc_thread_t *p_handle, void *(*entry) (void *),
void *data, int priority)
{
return vlc_clone_attr (p_handle, false, entry, data, prioity);
}
void vlc_join (vlc_thread_t th, void **result)
{
do
......@@ -639,9 +645,14 @@ void vlc_join (vlc_thread_t th, void **result)
free (th);
}
int vlc_clone_detach (void *(*entry) (void *), void *data, int priority)
int vlc_clone_detach (vlc_thread_t *p_handle, void *(*entry) (void *),
void *data, int priority)
{
return vlc_clone (NULL, entry, data, priority);
vlc_thread_t th;
if (p_handle == NULL)
p_handle = &th;
return vlc_clone_attr (p_handle, true, entry, data, priority);
}
/*** Thread cancellation ***/
......
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