]> git.sesse.net Git - vlc/blob - include/vlc_threads_funcs.h
Rework threading:
[vlc] / include / vlc_threads_funcs.h
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
6  * $Id$
7  *
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>
12  *
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.
17  *
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.
22  *
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  *****************************************************************************/
27
28 #if !defined( __LIBVLC__ )
29   #error You are not libvlc or one of its plugins. You cannot include this file
30 #endif
31
32 #ifndef _VLC_THREADFUNCS_H_
33 #define _VLC_THREADFUNCS_H_
34
35 /*****************************************************************************
36  * Function definitions
37  *****************************************************************************/
38 VLC_EXPORT( int,  __vlc_mutex_init,    ( vlc_object_t *, vlc_mutex_t * ) );
39 VLC_EXPORT( int,  __vlc_mutex_init_recursive, ( vlc_object_t *, vlc_mutex_t * ) );
40 VLC_EXPORT( void,  __vlc_mutex_destroy, ( const char *, int, vlc_mutex_t * ) );
41 VLC_EXPORT( int,  __vlc_cond_init,     ( vlc_object_t *, vlc_cond_t * ) );
42 VLC_EXPORT( void,  __vlc_cond_destroy,  ( const char *, int, vlc_cond_t * ) );
43 VLC_EXPORT( int, __vlc_threadvar_create, (vlc_object_t *, vlc_threadvar_t * ) );
44 VLC_EXPORT( int,  __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( void * ), int, vlc_bool_t ) );
45 VLC_EXPORT( int,  __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) );
46 VLC_EXPORT( void, __vlc_thread_ready,  ( vlc_object_t * ) );
47 VLC_EXPORT( void, __vlc_thread_join,   ( vlc_object_t *, const char *, int ) );
48
49 /*****************************************************************************
50  * vlc_threads_init: initialize threads system
51  *****************************************************************************/
52 #define vlc_threads_init( P_THIS )                                          \
53     __vlc_threads_init( VLC_OBJECT(P_THIS) )
54
55 /*****************************************************************************
56  * vlc_threads_end: deinitialize threads system
57  *****************************************************************************/
58 #define vlc_threads_end( P_THIS )                                           \
59     __vlc_threads_end( VLC_OBJECT(P_THIS) )
60
61 /*****************************************************************************
62  * vlc_mutex_init: initialize a mutex
63  *****************************************************************************/
64 #define vlc_mutex_init( P_THIS, P_MUTEX )                                   \
65     __vlc_mutex_init( VLC_OBJECT(P_THIS), P_MUTEX )
66
67 /*****************************************************************************
68  * vlc_mutex_init: initialize a recursive mutex (Don't use it)
69  *****************************************************************************/
70 #define vlc_mutex_init_recursive( P_THIS, P_MUTEX )                         \
71     __vlc_mutex_init_recursive( VLC_OBJECT(P_THIS), P_MUTEX )
72
73 /*****************************************************************************
74  * vlc_mutex_lock: lock a mutex
75  *****************************************************************************/
76 #define vlc_mutex_lock( P_MUTEX )                                           \
77     __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
78
79 #if defined(LIBVLC_USE_PTHREAD)
80 VLC_EXPORT(void, vlc_pthread_fatal, (const char *action, int error, const char *file, unsigned line));
81
82 # define VLC_THREAD_ASSERT( action ) \
83     if (val) \
84         vlc_pthread_fatal (action, val, psz_file, i_line)
85 #else
86 # define VLC_THREAD_ASSERT (void)0
87 #endif
88
89 static inline void __vlc_mutex_lock( const char * psz_file, int i_line,
90                                     vlc_mutex_t * p_mutex )
91 {
92 #if defined( UNDER_CE )
93     EnterCriticalSection( &p_mutex->csection );
94
95 #elif defined( WIN32 )
96     if( p_mutex->mutex )
97         WaitForSingleObject( p_mutex->mutex, INFINITE );
98     else
99         EnterCriticalSection( &p_mutex->csection );
100
101 #elif defined( HAVE_KERNEL_SCHEDULER_H )
102     acquire_sem( p_mutex->lock );
103
104 #elif defined(LIBVLC_USE_PTHREAD)
105 #   define vlc_assert_locked( m ) \
106            assert (pthread_mutex_lock (&((m)->mutex)) == EDEADLK)
107     int val = pthread_mutex_lock( &p_mutex->mutex );
108     VLC_THREAD_ASSERT ("locking mutex");
109
110 #endif
111 }
112
113 #ifndef vlc_assert_locked
114 # define vlc_assert_locked( m ) (void)0
115 #endif
116
117 /*****************************************************************************
118  * vlc_mutex_unlock: unlock a mutex
119  *****************************************************************************/
120 #define vlc_mutex_unlock( P_MUTEX )                                         \
121     __vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
122
123 static inline void __vlc_mutex_unlock( const char * psz_file, int i_line,
124                                       vlc_mutex_t *p_mutex )
125 {
126 #if defined( UNDER_CE )
127     LeaveCriticalSection( &p_mutex->csection );
128
129 #elif defined( WIN32 )
130     if( p_mutex->mutex )
131         ReleaseMutex( p_mutex->mutex );
132     else
133         LeaveCriticalSection( &p_mutex->csection );
134
135 #elif defined( HAVE_KERNEL_SCHEDULER_H )
136     release_sem( p_mutex->lock );
137
138 #elif defined(LIBVLC_USE_PTHREAD)
139     int val = pthread_mutex_unlock( &p_mutex->mutex );
140     VLC_THREAD_ASSERT ("unlocking mutex");
141
142 #endif
143 }
144
145 /*****************************************************************************
146  * vlc_mutex_destroy: destroy a mutex
147  *****************************************************************************/
148 #define vlc_mutex_destroy( P_MUTEX )                                        \
149     __vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
150
151 /*****************************************************************************
152  * vlc_cond_init: initialize a condition
153  *****************************************************************************/
154 #define vlc_cond_init( P_THIS, P_COND )                                     \
155     __vlc_cond_init( VLC_OBJECT(P_THIS), P_COND )
156
157 /*****************************************************************************
158  * vlc_cond_signal: start a thread on condition completion
159  *****************************************************************************/
160 #define vlc_cond_signal( P_COND )                                           \
161     __vlc_cond_signal( __FILE__, __LINE__, P_COND )
162
163 static inline void __vlc_cond_signal( const char * psz_file, int i_line,
164                                       vlc_cond_t *p_condvar )
165 {
166 #if defined( UNDER_CE )
167     PulseEvent( p_condvar->event );
168
169 #elif defined( WIN32 )
170     /* Release one waiting thread if one is available. */
171     /* For this trick to work properly, the vlc_cond_signal must be surrounded
172      * by a mutex. This will prevent another thread from stealing the signal */
173     if( !p_condvar->semaphore )
174     {
175         /* PulseEvent() only works if none of the waiting threads is suspended.
176          * This is particularily problematic under a debug session.
177          * as documented in http://support.microsoft.com/kb/q173260/ */
178         PulseEvent( p_condvar->event );
179     }
180     else if( p_condvar->i_win9x_cv == 1 )
181     {
182         /* Wait for the gate to be open */
183         WaitForSingleObject( p_condvar->event, INFINITE );
184
185         if( p_condvar->i_waiting_threads )
186         {
187             /* Using a semaphore exposes us to a race condition. It is
188              * possible for another thread to start waiting on the semaphore
189              * just after we signaled it and thus steal the signal.
190              * We have to prevent new threads from entering the cond_wait(). */
191             ResetEvent( p_condvar->event );
192
193             /* A semaphore is used here because Win9x doesn't have
194              * SignalObjectAndWait() and thus a race condition exists
195              * during the time we release the mutex and the time we start
196              * waiting on the event (more precisely, the signal can sometimes
197              * be missed by the waiting thread if we use PulseEvent()). */
198             ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
199         }
200     }
201     else
202     {
203         if( p_condvar->i_waiting_threads )
204         {
205             ReleaseSemaphore( p_condvar->semaphore, 1, 0 );
206
207             /* Wait for the last thread to be awakened */
208             WaitForSingleObject( p_condvar->event, INFINITE );
209         }
210     }
211
212 #elif defined( HAVE_KERNEL_SCHEDULER_H )
213     while( p_condvar->thread != -1 )
214     {
215         thread_info info;
216         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
217             return;
218
219         if( info.state != B_THREAD_SUSPENDED )
220         {
221             /* The  waiting thread is not suspended so it could
222              * have been interrupted beetwen the unlock and the
223              * suspend_thread line. That is why we sleep a little
224              * before retesting p_condver->thread. */
225             snooze( 10000 );
226         }
227         else
228         {
229             /* Ok, we have to wake up that thread */
230             resume_thread( p_condvar->thread );
231         }
232     }
233
234 #elif defined(LIBVLC_USE_PTHREAD)
235     int val = pthread_cond_signal( &p_condvar->cond );
236     VLC_THREAD_ASSERT ("signaling condition variable");
237
238 #endif
239 }
240
241 /*****************************************************************************
242  * vlc_cond_wait: wait until condition completion
243  *****************************************************************************/
244 #define vlc_cond_wait( P_COND, P_MUTEX )                                     \
245     __vlc_cond_wait( __FILE__, __LINE__, P_COND, P_MUTEX  )
246
247 static inline void __vlc_cond_wait( const char * psz_file, int i_line,
248                                     vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
249 {
250 #if defined( UNDER_CE )
251     p_condvar->i_waiting_threads++;
252     LeaveCriticalSection( &p_mutex->csection );
253     WaitForSingleObject( p_condvar->event, INFINITE );
254     p_condvar->i_waiting_threads--;
255
256     /* Reacquire the mutex before returning. */
257     vlc_mutex_lock( p_mutex );
258
259 #elif defined( WIN32 )
260     if( !p_condvar->semaphore )
261     {
262         /* Increase our wait count */
263         p_condvar->i_waiting_threads++;
264
265         if( p_mutex->mutex )
266         {
267             /* It is only possible to atomically release the mutex and
268              * initiate the waiting on WinNT/2K/XP. Win9x doesn't have
269              * SignalObjectAndWait(). */
270             p_condvar->SignalObjectAndWait( p_mutex->mutex,
271                                             p_condvar->event,
272                                             INFINITE, FALSE );
273         }
274         else
275         {
276             LeaveCriticalSection( &p_mutex->csection );
277             WaitForSingleObject( p_condvar->event, INFINITE );
278         }
279
280         p_condvar->i_waiting_threads--;
281     }
282     else if( p_condvar->i_win9x_cv == 1 )
283     {
284         int i_waiting_threads;
285
286         /* Wait for the gate to be open */
287         WaitForSingleObject( p_condvar->event, INFINITE );
288
289         /* Increase our wait count */
290         p_condvar->i_waiting_threads++;
291
292         LeaveCriticalSection( &p_mutex->csection );
293         WaitForSingleObject( p_condvar->semaphore, INFINITE );
294
295         /* Decrement and test must be atomic */
296         EnterCriticalSection( &p_condvar->csection );
297
298         /* Decrease our wait count */
299         i_waiting_threads = --p_condvar->i_waiting_threads;
300
301         LeaveCriticalSection( &p_condvar->csection );
302
303         /* Reopen the gate if we were the last waiting thread */
304         if( !i_waiting_threads )
305             SetEvent( p_condvar->event );
306     }
307     else
308     {
309         int i_waiting_threads;
310
311         /* Increase our wait count */
312         p_condvar->i_waiting_threads++;
313
314         LeaveCriticalSection( &p_mutex->csection );
315         WaitForSingleObject( p_condvar->semaphore, INFINITE );
316
317         /* Decrement and test must be atomic */
318         EnterCriticalSection( &p_condvar->csection );
319
320         /* Decrease our wait count */
321         i_waiting_threads = --p_condvar->i_waiting_threads;
322
323         LeaveCriticalSection( &p_condvar->csection );
324
325         /* Signal that the last waiting thread just went through */
326         if( !i_waiting_threads )
327             SetEvent( p_condvar->event );
328     }
329
330     /* Reacquire the mutex before returning. */
331     vlc_mutex_lock( p_mutex );
332
333 #elif defined( HAVE_KERNEL_SCHEDULER_H )
334     /* The p_condvar->thread var is initialized before the unlock because
335      * it enables to identify when the thread is interrupted beetwen the
336      * unlock line and the suspend_thread line */
337     p_condvar->thread = find_thread( NULL );
338     vlc_mutex_unlock( p_mutex );
339     suspend_thread( p_condvar->thread );
340     p_condvar->thread = -1;
341
342     vlc_mutex_lock( p_mutex );
343
344 #elif defined(LIBVLC_USE_PTHREAD)
345     int val = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex );
346     VLC_THREAD_ASSERT ("waiting on condition");
347
348 #endif
349 }
350
351
352 /*****************************************************************************
353  * vlc_cond_timedwait: wait until condition completion or expiration
354  *****************************************************************************
355  * Returns 0 if object signaled, an error code in case of timeout or error.
356  *****************************************************************************/
357 #define vlc_cond_timedwait( P_COND, P_MUTEX, DEADLINE )                      \
358     __vlc_cond_timedwait( __FILE__, __LINE__, P_COND, P_MUTEX, DEADLINE  )
359
360 static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
361                                         vlc_cond_t *p_condvar,
362                                         vlc_mutex_t *p_mutex,
363                                         mtime_t deadline )
364 {
365 #if defined( UNDER_CE )
366     mtime_t delay_ms = (deadline - mdate())/1000;
367
368     DWORD result;
369     if( delay_ms < 0 )
370         delay_ms = 0;
371
372     p_condvar->i_waiting_threads++;
373     LeaveCriticalSection( &p_mutex->csection );
374     result = WaitForSingleObject( p_condvar->event, delay_ms );
375     p_condvar->i_waiting_threads--;
376
377     /* Reacquire the mutex before returning. */
378     vlc_mutex_lock( p_mutex );
379
380     if(result == WAIT_TIMEOUT)
381        return ETIMEDOUT; /* this error is perfectly normal */
382
383 #elif defined( WIN32 )
384     DWORD result;
385
386     mtime_t delay_ms = (deadline - mdate())/1000;
387     if( delay_ms < 0 )
388         delay_ms = 0;
389
390     if( !p_condvar->semaphore )
391     {
392         /* Increase our wait count */
393         p_condvar->i_waiting_threads++;
394
395         if( p_mutex->mutex )
396         {
397             /* It is only possible to atomically release the mutex and
398              * initiate the waiting on WinNT/2K/XP. Win9x doesn't have
399              * SignalObjectAndWait(). */
400             result = p_condvar->SignalObjectAndWait( p_mutex->mutex,
401                                             p_condvar->event,
402                                             delay_ms, FALSE );
403         }
404         else
405         {
406             LeaveCriticalSection( &p_mutex->csection );
407             result = WaitForSingleObject( p_condvar->event, delay_ms );
408         }
409
410         p_condvar->i_waiting_threads--;
411     }
412     else if( p_condvar->i_win9x_cv == 1 )
413     {
414         int i_waiting_threads;
415
416         /* Wait for the gate to be open */
417         result = WaitForSingleObject( p_condvar->event, delay_ms );
418
419         /* Increase our wait count */
420         p_condvar->i_waiting_threads++;
421
422         LeaveCriticalSection( &p_mutex->csection );
423         if( !result )
424         {
425             /* recaculate remaining delay */
426             delay_ms = (deadline - mdate())/1000;
427             if( delay_ms < 0 )
428                 delay_ms = 0;
429
430             result = WaitForSingleObject( p_condvar->semaphore, delay_ms );
431         }
432
433         /* Decrement and test must be atomic */
434         EnterCriticalSection( &p_condvar->csection );
435
436         /* Decrease our wait count */
437         i_waiting_threads = --p_condvar->i_waiting_threads;
438
439         LeaveCriticalSection( &p_condvar->csection );
440
441         /* Reopen the gate if we were the last waiting thread */
442         if( !i_waiting_threads )
443             SetEvent( p_condvar->event );
444     }
445     else
446     {
447         int i_waiting_threads;
448
449         /* Increase our wait count */
450         p_condvar->i_waiting_threads++;
451
452         LeaveCriticalSection( &p_mutex->csection );
453         result = WaitForSingleObject( p_condvar->semaphore, delay_ms );
454
455         /* Decrement and test must be atomic */
456         EnterCriticalSection( &p_condvar->csection );
457
458         /* Decrease our wait count */
459         i_waiting_threads = --p_condvar->i_waiting_threads;
460
461         LeaveCriticalSection( &p_condvar->csection );
462
463         /* Signal that the last waiting thread just went through */
464         if( !i_waiting_threads )
465             SetEvent( p_condvar->event );
466     }
467
468     /* Reacquire the mutex before returning. */
469     vlc_mutex_lock( p_mutex );
470     if(result == WAIT_TIMEOUT)
471        return ETIMEDOUT; /* this error is perfectly normal */
472
473 #elif defined( HAVE_KERNEL_SCHEDULER_H )
474 #   error Unimplemented
475
476 #elif defined(LIBVLC_USE_PTHREAD)
477     lldiv_t d = lldiv( deadline, 1000000 );
478     struct timespec ts = { d.quot, d.rem * 1000 };
479
480     int val = pthread_cond_timedwait (&p_condvar->cond, &p_mutex->mutex, &ts);
481     if (val == ETIMEDOUT)
482         return ETIMEDOUT; /* this error is perfectly normal */
483     VLC_THREAD_ASSERT ("timed-waiting on condition");
484
485 #endif
486
487     return 0;
488 }
489
490 /*****************************************************************************
491  * vlc_cond_destroy: destroy a condition
492  *****************************************************************************/
493 #define vlc_cond_destroy( P_COND )                                          \
494     __vlc_cond_destroy( __FILE__, __LINE__, P_COND )
495
496 /*****************************************************************************
497  * vlc_threadvar_create: create a thread-local variable
498  *****************************************************************************/
499 #define vlc_threadvar_create( PTHIS, P_TLS )                                 \
500    __vlc_threadvar_create( PTHIS, P_TLS )
501
502 /*****************************************************************************
503  * vlc_threadvar_set: create: set the value of a thread-local variable
504  *****************************************************************************/
505 static inline int vlc_threadvar_set( vlc_threadvar_t * p_tls, void *p_value )
506 {
507     int i_ret;
508
509 #if defined( HAVE_KERNEL_SCHEDULER_H )
510     return -1;
511
512 #elif defined( UNDER_CE ) || defined( WIN32 )
513     i_ret = ( TlsSetValue( p_tls->handle, p_value ) != 0 );
514
515 #elif defined(LIBVLC_USE_PTHREAD)
516     i_ret = pthread_setspecific( p_tls->handle, p_value );
517
518 #endif
519
520     return i_ret;
521 }
522
523 /*****************************************************************************
524  * vlc_threadvar_get: create: get the value of a thread-local variable
525  *****************************************************************************/
526 static inline void* vlc_threadvar_get( vlc_threadvar_t * p_tls )
527 {
528     void* p_ret;
529
530 #if defined( HAVE_KERNEL_SCHEDULER_H )
531     p_ret = NULL;
532 #elif defined( UNDER_CE ) || defined( WIN32 )
533     p_ret = TlsGetValue( p_tls->handle );
534
535 #elif defined(LIBVLC_USE_PTHREAD)
536     p_ret = pthread_getspecific( p_tls->handle );
537
538 #endif
539
540     return p_ret;
541 }
542
543 # if defined (_POSIX_SPIN_LOCKS) && ((_POSIX_SPIN_LOCKS - 0) > 0)
544 typedef struct
545 {
546     pthread_spinlock_t  spin;
547 } vlc_spinlock_t;
548
549 /**
550  * Initializes a spinlock.
551  */
552 static inline int vlc_spin_init (vlc_spinlock_t *spin)
553 {
554     return pthread_spin_init (&spin->spin, PTHREAD_PROCESS_PRIVATE);
555 }
556
557 /**
558  * Acquires a spinlock.
559  */
560 static inline void vlc_spin_lock (vlc_spinlock_t *spin)
561 {
562     int val = pthread_spin_lock (&spin->spin);
563     assert (val == 0);
564 }
565
566 /**
567  * Releases a spinlock.
568  */
569 static inline void vlc_spin_unlock (vlc_spinlock_t *spin)
570 {
571     int val = pthread_spin_unlock (&spin->spin);
572     assert (val == 0);
573 }
574
575 /**
576  * Deinitializes a spinlock.
577  */
578 static inline void vlc_spin_destroy (vlc_spinlock_t *spin)
579 {
580     int val = pthread_spin_destroy (&spin->spin);
581     assert (val == 0);
582 }
583
584 #elif defined( WIN32 )
585
586 typedef CRITICAL_SECTION vlc_spinlock_t;
587
588 /**
589  * Initializes a spinlock.
590  */
591 static inline int vlc_spin_init (vlc_spinlock_t *spin)
592 {
593     return !InitializeCriticalSectionAndSpinCount(spin, 4000);
594 }
595
596 /**
597  * Acquires a spinlock.
598  */
599 static inline void vlc_spin_lock (vlc_spinlock_t *spin)
600 {
601     EnterCriticalSection(spin);
602 }
603
604 /**
605  * Releases a spinlock.
606  */
607 static inline void vlc_spin_unlock (vlc_spinlock_t *spin)
608 {
609     LeaveCriticalSection(spin);
610 }
611
612 /**
613  * Deinitializes a spinlock.
614  */
615 static inline void vlc_spin_destroy (vlc_spinlock_t *spin)
616 {
617     DeleteCriticalSection(spin);
618     return 0;
619 }
620
621
622 #else
623
624 /* Fallback to plain mutexes if spinlocks are not available */
625 typedef vlc_mutex_t vlc_spinlock_t;
626
627 static inline int vlc_spin_init (vlc_spinlock_t *spin)
628 {
629     return __vlc_mutex_init (NULL, spin);
630 }
631
632 # define vlc_spin_lock    vlc_mutex_lock
633 # define vlc_spin_unlock  vlc_mutex_unlock
634 # define vlc_spin_destroy vlc_mutex_destroy
635 #endif
636
637 /*****************************************************************************
638  * vlc_thread_create: create a thread
639  *****************************************************************************/
640 #define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, PRIORITY, WAIT )         \
641     __vlc_thread_create( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, (void * ( * ) ( void * ))FUNC, PRIORITY, WAIT )
642
643 /*****************************************************************************
644  * vlc_thread_set_priority: set the priority of the calling thread
645  *****************************************************************************/
646 #define vlc_thread_set_priority( P_THIS, PRIORITY )                         \
647     __vlc_thread_set_priority( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PRIORITY )
648
649 /*****************************************************************************
650  * vlc_thread_ready: tell the parent thread we were successfully spawned
651  *****************************************************************************/
652 #define vlc_thread_ready( P_THIS )                                          \
653     __vlc_thread_ready( VLC_OBJECT(P_THIS) )
654
655 /*****************************************************************************
656  * vlc_thread_join: wait until a thread exits
657  *****************************************************************************/
658 #define vlc_thread_join( P_THIS )                                           \
659     __vlc_thread_join( VLC_OBJECT(P_THIS), __FILE__, __LINE__ )
660
661 #endif