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