1 /*****************************************************************************
2 * vlc_threads_funcs.h : threads implementation for the VideoLAN client
3 * This header provides a portable threads implementation.
4 *****************************************************************************
5 * Copyright (C) 1999-2007 the VideoLAN team
8 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
9 * Samuel Hocevar <sam@via.ecp.fr>
10 * Gildas Bazin <gbazin@netcourrier.com>
11 * Christophe Massiot <massiot@via.ecp.fr>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
28 #if !defined( __LIBVLC__ )
29 #error You are not libvlc or one of its plugins. You cannot include this file
32 #ifndef _VLC_THREADFUNCS_H_
33 #define _VLC_THREADFUNCS_H_
35 /*****************************************************************************
36 * Function definitions
37 *****************************************************************************/
38 VLC_EXPORT( void, vlc_threads_error, ( vlc_object_t *) );
39 VLC_EXPORT( int, __vlc_mutex_init, ( vlc_object_t *, vlc_mutex_t * ) );
40 VLC_EXPORT( int, __vlc_mutex_init_recursive, ( vlc_object_t *, vlc_mutex_t * ) );
41 VLC_EXPORT( int, __vlc_mutex_destroy, ( const char *, int, vlc_mutex_t * ) );
42 VLC_EXPORT( int, __vlc_cond_init, ( vlc_object_t *, vlc_cond_t * ) );
43 VLC_EXPORT( int, __vlc_cond_destroy, ( const char *, int, vlc_cond_t * ) );
44 VLC_EXPORT( int, __vlc_threadvar_create, (vlc_object_t *, vlc_threadvar_t * ) );
45 VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( void * ), int, vlc_bool_t ) );
46 VLC_EXPORT( int, __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) );
47 VLC_EXPORT( void, __vlc_thread_ready, ( vlc_object_t * ) );
48 VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, const char *, int ) );
50 /*****************************************************************************
51 * vlc_threads_error: Signalize an error in the threading system
52 *****************************************************************************/
54 # define vlc_threads_error( P_THIS ) (void)0
57 /*****************************************************************************
58 * vlc_threads_init: initialize threads system
59 *****************************************************************************/
60 #define vlc_threads_init( P_THIS ) \
61 __vlc_threads_init( VLC_OBJECT(P_THIS) )
63 /*****************************************************************************
64 * vlc_threads_end: deinitialize threads system
65 *****************************************************************************/
66 #define vlc_threads_end( P_THIS ) \
67 __vlc_threads_end( VLC_OBJECT(P_THIS) )
69 /*****************************************************************************
70 * vlc_mutex_init: initialize a mutex
71 *****************************************************************************/
72 #define vlc_mutex_init( P_THIS, P_MUTEX ) \
73 __vlc_mutex_init( VLC_OBJECT(P_THIS), P_MUTEX )
75 /*****************************************************************************
76 * vlc_mutex_init: initialize a recursive mutex (Don't use it)
77 *****************************************************************************/
78 #define vlc_mutex_init_recursive( P_THIS, P_MUTEX ) \
79 __vlc_mutex_init_recursive( VLC_OBJECT(P_THIS), P_MUTEX )
81 /*****************************************************************************
82 * vlc_mutex_lock: lock a mutex
83 *****************************************************************************/
84 #define vlc_mutex_lock( P_MUTEX ) \
85 __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
87 #if defined(LIBVLC_USE_PTHREAD)
88 static inline unsigned long int CAST_PTHREAD_TO_INT (pthread_t th)
90 union { pthread_t th; unsigned long int i; } v = { };
96 static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
97 vlc_mutex_t * p_mutex )
100 /* In case of error : */
101 unsigned long int i_thread = 0;
103 #if defined( UNDER_CE )
104 EnterCriticalSection( &p_mutex->csection );
107 #elif defined( WIN32 )
110 WaitForSingleObject( p_mutex->mutex, INFINITE );
114 EnterCriticalSection( &p_mutex->csection );
118 #elif defined( HAVE_KERNEL_SCHEDULER_H )
119 if( p_mutex == NULL )
121 i_result = B_BAD_VALUE;
123 else if( p_mutex->init < 2000 )
125 i_result = B_NO_INIT;
129 i_result = acquire_sem( p_mutex->lock );
132 #elif defined(LIBVLC_USE_PTHREAD)
133 # define vlc_assert_locked( m ) \
134 assert (pthread_mutex_lock (&((m)->mutex)) == EDEADLK)
136 i_result = pthread_mutex_lock( &p_mutex->mutex );
139 i_thread = CAST_PTHREAD_TO_INT(pthread_self());
147 msg_Err( p_mutex->p_this,
148 "thread %li: mutex_lock failed at %s:%d (%d:%m)",
149 i_thread, psz_file, i_line, i_result );
150 vlc_threads_error( p_mutex->p_this );
155 #ifndef vlc_assert_locked
156 # define vlc_assert_locked( m ) (void)0
159 /*****************************************************************************
160 * vlc_mutex_unlock: unlock a mutex
161 *****************************************************************************/
162 #define vlc_mutex_unlock( P_MUTEX ) \
163 __vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
165 static inline int __vlc_mutex_unlock( const char * psz_file, int i_line,
166 vlc_mutex_t *p_mutex )
169 /* In case of error : */
170 unsigned long int i_thread = 0;
172 #if defined( UNDER_CE )
173 LeaveCriticalSection( &p_mutex->csection );
176 #elif defined( WIN32 )
179 ReleaseMutex( p_mutex->mutex );
183 LeaveCriticalSection( &p_mutex->csection );
187 #elif defined( HAVE_KERNEL_SCHEDULER_H )
188 if( p_mutex == NULL )
190 i_result = B_BAD_VALUE;
192 else if( p_mutex->init < 2000 )
194 i_result = B_NO_INIT;
198 release_sem( p_mutex->lock );
202 #elif defined(LIBVLC_USE_PTHREAD)
203 i_result = pthread_mutex_unlock( &p_mutex->mutex );
206 i_thread = CAST_PTHREAD_TO_INT(pthread_self());
214 msg_Err( p_mutex->p_this,
215 "thread %li: mutex_unlock failed at %s:%d (%d:%m)",
216 i_thread, psz_file, i_line, i_result );
217 vlc_threads_error( p_mutex->p_this );
223 /*****************************************************************************
224 * vlc_mutex_destroy: destroy a mutex
225 *****************************************************************************/
226 #define vlc_mutex_destroy( P_MUTEX ) \
227 __vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
229 /*****************************************************************************
230 * vlc_cond_init: initialize a condition
231 *****************************************************************************/
232 #define vlc_cond_init( P_THIS, P_COND ) \
233 __vlc_cond_init( VLC_OBJECT(P_THIS), P_COND )
235 /*****************************************************************************
236 * vlc_cond_signal: start a thread on condition completion
237 *****************************************************************************/
238 #define vlc_cond_signal( P_COND ) \
239 __vlc_cond_signal( __FILE__, __LINE__, P_COND )
241 static inline int __vlc_cond_signal( const char * psz_file, int i_line,
242 vlc_cond_t *p_condvar )
245 /* In case of error : */
246 unsigned long int i_thread = 0;
248 #if defined( UNDER_CE )
249 PulseEvent( p_condvar->event );
252 #elif defined( WIN32 )
253 /* Release one waiting thread if one is available. */
254 /* For this trick to work properly, the vlc_cond_signal must be surrounded
255 * by a mutex. This will prevent another thread from stealing the signal */
256 if( !p_condvar->semaphore )
259 ** PulseEvent() only works if none of the waiting threads is suspended.
260 ** this is particularily problematic under a debug session.
261 ** as documented in http://support.microsoft.com/kb/q173260/
263 PulseEvent( p_condvar->event );
265 else if( p_condvar->i_win9x_cv == 1 )
267 /* Wait for the gate to be open */
268 WaitForSingleObject( p_condvar->event, INFINITE );
270 if( p_condvar->i_waiting_threads )
272 /* Using a semaphore exposes us to a race condition. It is
273 * possible for another thread to start waiting on the semaphore
274 * just after we signaled it and thus steal the signal.
275 * We have to prevent new threads from entering the cond_wait(). */
276 ResetEvent( p_condvar->event );
278 /* A semaphore is used here because Win9x doesn't have
279 * SignalObjectAndWait() and thus a race condition exists
280 * during the time we release the mutex and the time we start
281 * waiting on the event (more precisely, the signal can sometimes
282 * be missed by the waiting thread if we use PulseEvent()). */
283 ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
288 if( p_condvar->i_waiting_threads )
290 ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
292 /* Wait for the last thread to be awakened */
293 WaitForSingleObject( p_condvar->event, INFINITE );
298 #elif defined( HAVE_KERNEL_SCHEDULER_H )
299 if( p_condvar == NULL )
301 i_result = B_BAD_VALUE;
303 else if( p_condvar->init < 2000 )
305 i_result = B_NO_INIT;
309 while( p_condvar->thread != -1 )
312 if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
317 if( info.state != B_THREAD_SUSPENDED )
319 /* The waiting thread is not suspended so it could
320 * have been interrupted beetwen the unlock and the
321 * suspend_thread line. That is why we sleep a little
322 * before retesting p_condver->thread. */
327 /* Ok, we have to wake up that thread */
328 resume_thread( p_condvar->thread );
335 #elif defined(LIBVLC_USE_PTHREAD)
336 i_result = pthread_cond_signal( &p_condvar->cond );
339 i_thread = CAST_PTHREAD_TO_INT(pthread_self());
347 msg_Err( p_condvar->p_this,
348 "thread %li: cond_signal failed at %s:%d (%d:%m)",
349 i_thread, psz_file, i_line, i_result );
350 vlc_threads_error( p_condvar->p_this );
356 /*****************************************************************************
357 * vlc_cond_wait: wait until condition completion
358 *****************************************************************************/
359 #define vlc_cond_wait( P_COND, P_MUTEX ) \
360 __vlc_cond_wait( __FILE__, __LINE__, P_COND, P_MUTEX )
362 static inline int __vlc_cond_wait( const char * psz_file, int i_line,
363 vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
366 /* In case of error : */
367 unsigned long int i_thread = 0;
369 #if defined( UNDER_CE )
370 p_condvar->i_waiting_threads++;
371 LeaveCriticalSection( &p_mutex->csection );
372 WaitForSingleObject( p_condvar->event, INFINITE );
373 p_condvar->i_waiting_threads--;
375 /* Reacquire the mutex before returning. */
376 vlc_mutex_lock( p_mutex );
380 #elif defined( WIN32 )
381 if( !p_condvar->semaphore )
383 /* Increase our wait count */
384 p_condvar->i_waiting_threads++;
388 /* It is only possible to atomically release the mutex and
389 * initiate the waiting on WinNT/2K/XP. Win9x doesn't have
390 * SignalObjectAndWait(). */
391 p_condvar->SignalObjectAndWait( p_mutex->mutex,
397 LeaveCriticalSection( &p_mutex->csection );
398 WaitForSingleObject( p_condvar->event, INFINITE );
401 p_condvar->i_waiting_threads--;
403 else if( p_condvar->i_win9x_cv == 1 )
405 int i_waiting_threads;
407 /* Wait for the gate to be open */
408 WaitForSingleObject( p_condvar->event, INFINITE );
410 /* Increase our wait count */
411 p_condvar->i_waiting_threads++;
413 LeaveCriticalSection( &p_mutex->csection );
414 WaitForSingleObject( p_condvar->semaphore, INFINITE );
416 /* Decrement and test must be atomic */
417 EnterCriticalSection( &p_condvar->csection );
419 /* Decrease our wait count */
420 i_waiting_threads = --p_condvar->i_waiting_threads;
422 LeaveCriticalSection( &p_condvar->csection );
424 /* Reopen the gate if we were the last waiting thread */
425 if( !i_waiting_threads )
426 SetEvent( p_condvar->event );
430 int i_waiting_threads;
432 /* Increase our wait count */
433 p_condvar->i_waiting_threads++;
435 LeaveCriticalSection( &p_mutex->csection );
436 WaitForSingleObject( p_condvar->semaphore, INFINITE );
438 /* Decrement and test must be atomic */
439 EnterCriticalSection( &p_condvar->csection );
441 /* Decrease our wait count */
442 i_waiting_threads = --p_condvar->i_waiting_threads;
444 LeaveCriticalSection( &p_condvar->csection );
446 /* Signal that the last waiting thread just went through */
447 if( !i_waiting_threads )
448 SetEvent( p_condvar->event );
451 /* Reacquire the mutex before returning. */
452 vlc_mutex_lock( p_mutex );
456 #elif defined( HAVE_KERNEL_SCHEDULER_H )
457 if( p_condvar == NULL )
459 i_result = B_BAD_VALUE;
461 else if( p_mutex == NULL )
463 i_result = B_BAD_VALUE;
465 else if( p_condvar->init < 2000 )
467 i_result = B_NO_INIT;
470 /* The p_condvar->thread var is initialized before the unlock because
471 * it enables to identify when the thread is interrupted beetwen the
472 * unlock line and the suspend_thread line */
473 p_condvar->thread = find_thread( NULL );
474 vlc_mutex_unlock( p_mutex );
475 suspend_thread( p_condvar->thread );
476 p_condvar->thread = -1;
478 vlc_mutex_lock( p_mutex );
481 #elif defined(LIBVLC_USE_PTHREAD)
484 /* In debug mode, timeout */
485 struct timespec timeout = {
486 (mdate() / 1000000) + THREAD_COND_TIMEOUT,
487 0 /* 1Hz precision is sufficient here :-) */
490 i_result = pthread_cond_timedwait( &p_condvar->cond, &p_mutex->mutex,
493 if( i_result == ETIMEDOUT )
496 msg_Dbg( p_condvar->p_this,
497 "thread %li: possible condition deadlock "
498 "at %s:%d (%m)", CAST_PTHREAD_TO_INT(pthread_self()),
501 i_result = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex );
505 i_result = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex );
510 i_thread = CAST_PTHREAD_TO_INT(pthread_self());
518 msg_Err( p_condvar->p_this,
519 "thread %li: cond_wait failed at %s:%d (%d:%m)",
520 i_thread, psz_file, i_line, i_result );
521 vlc_threads_error( p_condvar->p_this );
528 /*****************************************************************************
529 * vlc_cond_timedwait: wait until condition completion or expiration
530 *****************************************************************************
531 * Returns 0 if object signaled, an error code in case of timeout or error.
532 *****************************************************************************/
533 #define vlc_cond_timedwait( P_COND, P_MUTEX, DEADLINE ) \
534 __vlc_cond_timedwait( __FILE__, __LINE__, P_COND, P_MUTEX, DEADLINE )
536 static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
537 vlc_cond_t *p_condvar,
538 vlc_mutex_t *p_mutex,
542 unsigned long int i_thread = 0;
544 #if defined( UNDER_CE )
545 mtime_t delay_ms = (deadline - mdate())/1000;
551 p_condvar->i_waiting_threads++;
552 LeaveCriticalSection( &p_mutex->csection );
553 result = WaitForSingleObject( p_condvar->event, delay_ms );
554 p_condvar->i_waiting_threads--;
556 /* Reacquire the mutex before returning. */
557 vlc_mutex_lock( p_mutex );
560 if(result == WAIT_TIMEOUT)
561 return WAIT_TIMEOUT; /* this error is perfectly normal */
563 #elif defined( WIN32 )
566 mtime_t delay_ms = (deadline - mdate())/1000;
570 if( !p_condvar->semaphore )
572 /* Increase our wait count */
573 p_condvar->i_waiting_threads++;
577 /* It is only possible to atomically release the mutex and
578 * initiate the waiting on WinNT/2K/XP. Win9x doesn't have
579 * SignalObjectAndWait(). */
580 result = p_condvar->SignalObjectAndWait( p_mutex->mutex,
586 LeaveCriticalSection( &p_mutex->csection );
587 result = WaitForSingleObject( p_condvar->event, delay_ms );
590 p_condvar->i_waiting_threads--;
592 else if( p_condvar->i_win9x_cv == 1 )
594 int i_waiting_threads;
596 /* Wait for the gate to be open */
597 result = WaitForSingleObject( p_condvar->event, delay_ms );
599 /* Increase our wait count */
600 p_condvar->i_waiting_threads++;
602 LeaveCriticalSection( &p_mutex->csection );
605 /* recaculate remaining delay */
606 delay_ms = (deadline - mdate())/1000;
610 result = WaitForSingleObject( p_condvar->semaphore, delay_ms );
613 /* Decrement and test must be atomic */
614 EnterCriticalSection( &p_condvar->csection );
616 /* Decrease our wait count */
617 i_waiting_threads = --p_condvar->i_waiting_threads;
619 LeaveCriticalSection( &p_condvar->csection );
621 /* Reopen the gate if we were the last waiting thread */
622 if( !i_waiting_threads )
623 SetEvent( p_condvar->event );
627 int i_waiting_threads;
629 /* Increase our wait count */
630 p_condvar->i_waiting_threads++;
632 LeaveCriticalSection( &p_mutex->csection );
633 result = WaitForSingleObject( p_condvar->semaphore, delay_ms );
635 /* Decrement and test must be atomic */
636 EnterCriticalSection( &p_condvar->csection );
638 /* Decrease our wait count */
639 i_waiting_threads = --p_condvar->i_waiting_threads;
641 LeaveCriticalSection( &p_condvar->csection );
643 /* Signal that the last waiting thread just went through */
644 if( !i_waiting_threads )
645 SetEvent( p_condvar->event );
648 /* Reacquire the mutex before returning. */
649 vlc_mutex_lock( p_mutex );
650 if(result == WAIT_TIMEOUT)
651 return WAIT_TIMEOUT; /* this error is perfectly normal */
655 #elif defined( HAVE_KERNEL_SCHEDULER_H )
656 # error Unimplemented
657 #elif defined(LIBVLC_USE_PTHREAD)
658 lldiv_t d = lldiv( deadline, 1000000 );
659 struct timespec ts = { d.quot, d.rem * 1000 };
661 i_res = pthread_cond_timedwait( &p_condvar->cond, &p_mutex->mutex, &ts );
662 if( i_res == ETIMEDOUT )
663 return ETIMEDOUT; /* this error is perfectly normal */
665 if ( i_res ) /* other errors = bug */
667 i_thread = CAST_PTHREAD_TO_INT(pthread_self());
675 msg_Err( p_condvar->p_this,
676 "thread %li: cond_wait failed at %s:%d (%d:%m)",
677 i_thread, psz_file, i_line, i_res );
678 vlc_threads_error( p_condvar->p_this );
684 /*****************************************************************************
685 * vlc_cond_destroy: destroy a condition
686 *****************************************************************************/
687 #define vlc_cond_destroy( P_COND ) \
688 __vlc_cond_destroy( __FILE__, __LINE__, P_COND )
690 /*****************************************************************************
691 * vlc_threadvar_create: create a thread-local variable
692 *****************************************************************************/
693 #define vlc_threadvar_create( PTHIS, P_TLS ) \
694 __vlc_threadvar_create( PTHIS, P_TLS )
696 /*****************************************************************************
697 * vlc_threadvar_set: create: set the value of a thread-local variable
698 *****************************************************************************/
699 static inline int vlc_threadvar_set( vlc_threadvar_t * p_tls, void *p_value )
703 #if defined( HAVE_KERNEL_SCHEDULER_H )
706 #elif defined( UNDER_CE ) || defined( WIN32 )
707 i_ret = ( TlsSetValue( p_tls->handle, p_value ) != 0 );
709 #elif defined(LIBVLC_USE_PTHREAD)
710 i_ret = pthread_setspecific( p_tls->handle, p_value );
717 /*****************************************************************************
718 * vlc_threadvar_get: create: get the value of a thread-local variable
719 *****************************************************************************/
720 static inline void* vlc_threadvar_get( vlc_threadvar_t * p_tls )
724 #if defined( HAVE_KERNEL_SCHEDULER_H )
726 #elif defined( UNDER_CE ) || defined( WIN32 )
727 p_ret = TlsGetValue( p_tls->handle );
729 #elif defined(LIBVLC_USE_PTHREAD)
730 p_ret = pthread_getspecific( p_tls->handle );
737 # if defined (_POSIX_SPIN_LOCKS) && ((_POSIX_SPIN_LOCKS - 0) > 0)
740 pthread_spinlock_t spin;
744 * Initializes a spinlock.
746 static inline int vlc_spin_init (vlc_spinlock_t *spin)
748 return pthread_spin_init (&spin->spin, PTHREAD_PROCESS_PRIVATE);
752 * Acquires a spinlock.
754 static inline int vlc_spin_lock (vlc_spinlock_t *spin)
756 return pthread_spin_lock (&spin->spin);
760 * Releases a spinlock.
762 static inline int vlc_spin_unlock (vlc_spinlock_t *spin)
764 return pthread_spin_unlock (&spin->spin);
768 * Deinitializes a spinlock.
770 static inline int vlc_spin_destroy (vlc_spinlock_t *spin)
772 return pthread_spin_destroy (&spin->spin);
775 #elif defined( WIN32 )
777 typedef CRITICAL_SECTION vlc_spinlock_t;
780 * Initializes a spinlock.
782 static inline int vlc_spin_init (vlc_spinlock_t *spin)
784 return !InitializeCriticalSectionAndSpinCount(spin, 4000);
788 * Acquires a spinlock.
790 static inline int vlc_spin_lock (vlc_spinlock_t *spin)
792 EnterCriticalSection(spin);
797 * Releases a spinlock.
799 static inline int vlc_spin_unlock (vlc_spinlock_t *spin)
801 LeaveCriticalSection(spin);
806 * Deinitializes a spinlock.
808 static inline int vlc_spin_destroy (vlc_spinlock_t *spin)
810 DeleteCriticalSection(spin);
818 /* Fallback to plain mutexes if spinlocks are not available */
819 typedef vlc_mutex_t vlc_spinlock_t;
821 static inline int vlc_spin_init (vlc_spinlock_t *spin)
823 return __vlc_mutex_init (NULL, spin);
826 # define vlc_spin_lock vlc_mutex_lock
827 # define vlc_spin_unlock vlc_mutex_unlock
828 # define vlc_spin_destroy vlc_mutex_destroy
831 /*****************************************************************************
832 * vlc_thread_create: create a thread
833 *****************************************************************************/
834 #define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, PRIORITY, WAIT ) \
835 __vlc_thread_create( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, (void * ( * ) ( void * ))FUNC, PRIORITY, WAIT )
837 /*****************************************************************************
838 * vlc_thread_set_priority: set the priority of the calling thread
839 *****************************************************************************/
840 #define vlc_thread_set_priority( P_THIS, PRIORITY ) \
841 __vlc_thread_set_priority( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PRIORITY )
843 /*****************************************************************************
844 * vlc_thread_ready: tell the parent thread we were successfully spawned
845 *****************************************************************************/
846 #define vlc_thread_ready( P_THIS ) \
847 __vlc_thread_ready( VLC_OBJECT(P_THIS) )
849 /*****************************************************************************
850 * vlc_thread_join: wait until a thread exits
851 *****************************************************************************/
852 #define vlc_thread_join( P_THIS ) \
853 __vlc_thread_join( VLC_OBJECT(P_THIS), __FILE__, __LINE__ )