]> git.sesse.net Git - vlc/blob - include/vlc_threads.h
Support for cancelling self and use normal thread variable
[vlc] / include / vlc_threads.h
1 /*****************************************************************************
2  * vlc_threads.h : threads implementation for the VideoLAN client
3  * This header provides portable declarations for mutexes & conditions
4  *****************************************************************************
5  * Copyright (C) 1999, 2002 the VideoLAN team
6  * Copyright © 2007-2008 Rémi Denis-Courmont
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 #ifndef VLC_THREADS_H_
29 #define VLC_THREADS_H_
30
31 /**
32  * \file
33  * This file defines structures and functions for handling threads in vlc
34  *
35  */
36
37 #if defined( UNDER_CE )
38                                                                 /* WinCE API */
39 #elif defined( WIN32 )
40 #   include <process.h>                                         /* Win32 API */
41 #   include <errno.h>
42
43 #elif defined( SYS_BEOS )                                            /* BeOS */
44 #   include <kernel/OS.h>
45 #   include <kernel/scheduler.h>
46 #   include <byteorder.h>
47
48 #else                                         /* pthreads (like Linux & BSD) */
49 #   define LIBVLC_USE_PTHREAD 1
50 #   define _APPLE_C_SOURCE    1 /* Proper pthread semantics on OSX */
51
52 #   include <stdlib.h> /* lldiv_t definition (only in C99) */
53 #   include <unistd.h> /* _POSIX_SPIN_LOCKS */
54 #   include <pthread.h>
55     /* Needed for pthread_cond_timedwait */
56 #   include <errno.h>
57 #   include <time.h>
58
59 #endif
60
61 /*****************************************************************************
62  * Constants
63  *****************************************************************************/
64
65 /* Thread priorities */
66 #ifdef __APPLE__
67 #   define VLC_THREAD_PRIORITY_LOW      0
68 #   define VLC_THREAD_PRIORITY_INPUT   22
69 #   define VLC_THREAD_PRIORITY_AUDIO   22
70 #   define VLC_THREAD_PRIORITY_VIDEO    0
71 #   define VLC_THREAD_PRIORITY_OUTPUT  22
72 #   define VLC_THREAD_PRIORITY_HIGHEST 22
73
74 #elif defined(SYS_BEOS)
75 #   define VLC_THREAD_PRIORITY_LOW 5
76 #   define VLC_THREAD_PRIORITY_INPUT 10
77 #   define VLC_THREAD_PRIORITY_AUDIO 10
78 #   define VLC_THREAD_PRIORITY_VIDEO 5
79 #   define VLC_THREAD_PRIORITY_OUTPUT 15
80 #   define VLC_THREAD_PRIORITY_HIGHEST 15
81
82 #elif defined(LIBVLC_USE_PTHREAD)
83 #   define VLC_THREAD_PRIORITY_LOW      0
84 #   define VLC_THREAD_PRIORITY_INPUT   10
85 #   define VLC_THREAD_PRIORITY_AUDIO    5
86 #   define VLC_THREAD_PRIORITY_VIDEO    0
87 #   define VLC_THREAD_PRIORITY_OUTPUT  15
88 #   define VLC_THREAD_PRIORITY_HIGHEST 20
89
90 #elif defined(WIN32) || defined(UNDER_CE)
91 /* Define different priorities for WinNT/2K/XP and Win9x/Me */
92 #   define VLC_THREAD_PRIORITY_LOW 0
93 #   define VLC_THREAD_PRIORITY_INPUT \
94         (IS_WINNT ? THREAD_PRIORITY_ABOVE_NORMAL : 0)
95 #   define VLC_THREAD_PRIORITY_AUDIO \
96         (IS_WINNT ? THREAD_PRIORITY_HIGHEST : 0)
97 #   define VLC_THREAD_PRIORITY_VIDEO \
98         (IS_WINNT ? 0 : THREAD_PRIORITY_BELOW_NORMAL )
99 #   define VLC_THREAD_PRIORITY_OUTPUT \
100         (IS_WINNT ? THREAD_PRIORITY_ABOVE_NORMAL : 0)
101 #   define VLC_THREAD_PRIORITY_HIGHEST \
102         (IS_WINNT ? THREAD_PRIORITY_TIME_CRITICAL : 0)
103
104 #else
105 #   define VLC_THREAD_PRIORITY_LOW 0
106 #   define VLC_THREAD_PRIORITY_INPUT 0
107 #   define VLC_THREAD_PRIORITY_AUDIO 0
108 #   define VLC_THREAD_PRIORITY_VIDEO 0
109 #   define VLC_THREAD_PRIORITY_OUTPUT 0
110 #   define VLC_THREAD_PRIORITY_HIGHEST 0
111
112 #endif
113
114 /*****************************************************************************
115  * Type definitions
116  *****************************************************************************/
117
118 #if defined (LIBVLC_USE_PTHREAD)
119 typedef pthread_t       vlc_thread_t;
120 typedef pthread_mutex_t vlc_mutex_t;
121 typedef pthread_cond_t  vlc_cond_t;
122 typedef pthread_key_t   vlc_threadvar_t;
123
124 #elif defined( WIN32 ) || defined( UNDER_CE )
125 typedef struct
126 {
127     HANDLE handle;
128     void  *(*entry) (void *);
129     void  *data;
130 } *vlc_thread_t;
131
132 typedef HANDLE  vlc_mutex_t;
133 typedef HANDLE  vlc_cond_t;
134 typedef DWORD   vlc_threadvar_t;
135
136 #elif defined( SYS_BEOS )
137 /* This is the BeOS implementation of the vlc threads, note that the mutex is
138  * not a real mutex and the cond_var is not like a pthread cond_var but it is
139  * enough for what we need */
140
141 typedef thread_id vlc_thread_t;
142
143 typedef struct
144 {
145     int32_t         init;
146     sem_id          lock;
147 } vlc_mutex_t;
148
149 typedef struct
150 {
151     int32_t         init;
152     thread_id       thread;
153 } vlc_cond_t;
154
155 typedef struct
156 {
157 } vlc_threadvar_t;
158
159 #endif
160
161 #if defined( WIN32 ) && !defined ETIMEDOUT
162 #  define ETIMEDOUT 10060 /* This is the value in winsock.h. */
163 #endif
164
165 /*****************************************************************************
166  * Function definitions
167  *****************************************************************************/
168 VLC_EXPORT( int,  vlc_mutex_init,    ( vlc_mutex_t * ) );
169 VLC_EXPORT( int,  vlc_mutex_init_recursive, ( vlc_mutex_t * ) );
170 VLC_EXPORT( void,  __vlc_mutex_destroy, ( const char *, int, vlc_mutex_t * ) );
171 VLC_EXPORT( int,  __vlc_cond_init,     ( vlc_cond_t * ) );
172 VLC_EXPORT( void,  __vlc_cond_destroy,  ( const char *, int, vlc_cond_t * ) );
173 VLC_EXPORT( int, vlc_threadvar_create, (vlc_threadvar_t * , void (*) (void *) ) );
174 VLC_EXPORT( void, vlc_threadvar_delete, (vlc_threadvar_t *) );
175 VLC_EXPORT( int,  __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( vlc_object_t * ), int, bool ) );
176 VLC_EXPORT( int,  __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) );
177 VLC_EXPORT( void, __vlc_thread_join,   ( vlc_object_t *, const char *, int ) );
178
179 VLC_EXPORT( int, vlc_clone, (vlc_thread_t *, void * (*) (void *), void *, int) );
180 VLC_EXPORT( void, vlc_cancel, (vlc_thread_t) );
181 VLC_EXPORT( int, vlc_join, (vlc_thread_t, void **) );
182 VLC_EXPORT (void, vlc_control_cancel, (int cmd, ...));
183
184 #ifndef LIBVLC_USE_PTHREAD
185 enum {
186     VLC_SAVE_CANCEL,
187     VLC_RESTORE_CANCEL,
188     VLC_TEST_CANCEL,
189     VLC_DO_CANCEL,
190 };
191 #endif
192
193 #define vlc_thread_ready vlc_object_signal
194
195 /*****************************************************************************
196  * vlc_mutex_lock: lock a mutex
197  *****************************************************************************/
198 #define vlc_mutex_lock( P_MUTEX )                                           \
199     __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
200
201 VLC_EXPORT(void, vlc_pthread_fatal, (const char *action, int error, const char *file, unsigned line));
202
203 #if defined(LIBVLC_USE_PTHREAD)
204 # define VLC_THREAD_ASSERT( action ) \
205     if (val) \
206         vlc_pthread_fatal (action, val, psz_file, i_line)
207 #else
208 # define VLC_THREAD_ASSERT ((void)(val))
209 #endif
210
211 static inline void __vlc_mutex_lock( const char * psz_file, int i_line,
212                                     vlc_mutex_t * p_mutex )
213 {
214 #if defined(LIBVLC_USE_PTHREAD)
215 #   define vlc_assert_locked( m ) \
216            assert (pthread_mutex_lock (m) == EDEADLK)
217     int val = pthread_mutex_lock( p_mutex );
218     VLC_THREAD_ASSERT ("locking mutex");
219
220 #elif defined( UNDER_CE )
221     (void)psz_file; (void)i_line;
222
223     EnterCriticalSection( &p_mutex->csection );
224
225 #elif defined( WIN32 )
226     (void)psz_file; (void)i_line;
227
228     WaitForSingleObject( *p_mutex, INFINITE );
229
230 #elif defined( SYS_BEOS )
231     acquire_sem( p_mutex->lock );
232
233 #endif
234 }
235
236 #ifndef vlc_assert_locked
237 # define vlc_assert_locked( m ) (void)m
238 #endif
239
240 /*****************************************************************************
241  * vlc_mutex_unlock: unlock a mutex
242  *****************************************************************************/
243 #define vlc_mutex_unlock( P_MUTEX )                                         \
244     __vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
245
246 static inline void __vlc_mutex_unlock( const char * psz_file, int i_line,
247                                       vlc_mutex_t *p_mutex )
248 {
249 #if defined(LIBVLC_USE_PTHREAD)
250     int val = pthread_mutex_unlock( p_mutex );
251     VLC_THREAD_ASSERT ("unlocking mutex");
252
253 #elif defined( UNDER_CE )
254     (void)psz_file; (void)i_line;
255
256     LeaveCriticalSection( &p_mutex->csection );
257
258 #elif defined( WIN32 )
259     (void)psz_file; (void)i_line;
260
261     ReleaseMutex( *p_mutex );
262
263 #elif defined( SYS_BEOS )
264     release_sem( p_mutex->lock );
265
266 #endif
267 }
268
269 /*****************************************************************************
270  * vlc_mutex_destroy: destroy a mutex
271  *****************************************************************************/
272 #define vlc_mutex_destroy( P_MUTEX )                                        \
273     __vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
274
275 /**
276  * Save the cancellation state and disable cancellation for the calling thread.
277  * This function must be called before entering a piece of code that is not
278  * cancellation-safe.
279  * @return Previous cancellation state (opaque value).
280  */
281 static inline int vlc_savecancel (void)
282 {
283     int state;
284 #if defined (LIBVLC_USE_PTHREAD)
285     (void) pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
286 #else
287     vlc_control_cancel (VLC_SAVE_CANCEL, &state);
288 #endif
289     return state;
290 }
291
292 /**
293  * Restore the cancellation state for the calling thread.
294  * @param state previous state as returned by vlc_savecancel().
295  * @return Nothing, always succeeds.
296  */
297 static inline void vlc_restorecancel (int state)
298 {
299 #if defined (LIBVLC_USE_PTHREAD)
300     (void) pthread_setcancelstate (state, NULL);
301 #else
302     vlc_control_cancel (VLC_RESTORE_CANCEL, state);
303 #endif
304 }
305
306 /**
307  * Issues an explicit deferred cancellation point.
308  * This has no effect if thread cancellation is disabled.
309  * This can be called when there is a rather slow non-sleeping operation.
310  */
311 static inline void vlc_testcancel (void)
312 {
313 #if defined (LIBVLC_USE_PTHREAD)
314     pthread_testcancel ();
315 #else
316     vlc_control_cancel (VLC_TEST_CANCEL);
317 #endif
318 }
319
320 /*****************************************************************************
321  * vlc_cond_init: initialize a condition
322  *****************************************************************************/
323 #define vlc_cond_init( P_THIS, P_COND )                                     \
324     __vlc_cond_init( P_COND )
325
326 /*****************************************************************************
327  * vlc_cond_signal: start a thread on condition completion
328  *****************************************************************************/
329 #define vlc_cond_signal( P_COND )                                           \
330     __vlc_cond_signal( __FILE__, __LINE__, P_COND )
331
332 static inline void __vlc_cond_signal( const char * psz_file, int i_line,
333                                       vlc_cond_t *p_condvar )
334 {
335 #if defined(LIBVLC_USE_PTHREAD)
336     int val = pthread_cond_signal( p_condvar );
337     VLC_THREAD_ASSERT ("signaling condition variable");
338
339 #elif defined( UNDER_CE ) || defined( WIN32 )
340     (void)psz_file; (void)i_line;
341
342     /* Release one waiting thread if one is available. */
343     /* For this trick to work properly, the vlc_cond_signal must be surrounded
344      * by a mutex. This will prevent another thread from stealing the signal */
345     /* PulseEvent() only works if none of the waiting threads is suspended.
346      * This is particularily problematic under a debug session.
347      * as documented in http://support.microsoft.com/kb/q173260/ */
348     PulseEvent( *p_condvar );
349
350 #elif defined( SYS_BEOS )
351     while( p_condvar->thread != -1 )
352     {
353         thread_info info;
354         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
355             return;
356
357         if( info.state != B_THREAD_SUSPENDED )
358         {
359             /* The  waiting thread is not suspended so it could
360              * have been interrupted beetwen the unlock and the
361              * suspend_thread line. That is why we sleep a little
362              * before retesting p_condver->thread. */
363             snooze( 10000 );
364         }
365         else
366         {
367             /* Ok, we have to wake up that thread */
368             resume_thread( p_condvar->thread );
369         }
370     }
371
372 #endif
373 }
374
375 /*****************************************************************************
376  * vlc_cond_wait: wait until condition completion
377  *****************************************************************************/
378 #define vlc_cond_wait( P_COND, P_MUTEX )                                     \
379     __vlc_cond_wait( __FILE__, __LINE__, P_COND, P_MUTEX  )
380
381 static inline void __vlc_cond_wait( const char * psz_file, int i_line,
382                                     vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
383 {
384 #if defined(LIBVLC_USE_PTHREAD)
385     int val = pthread_cond_wait( p_condvar, p_mutex );
386     VLC_THREAD_ASSERT ("waiting on condition");
387
388 #elif defined( UNDER_CE )
389     LeaveCriticalSection( &p_mutex->csection );
390     WaitForSingleObject( *p_condvar, INFINITE );
391
392     /* Reacquire the mutex before returning. */
393     vlc_mutex_lock( p_mutex );
394
395 #elif defined( WIN32 )
396     (void)psz_file; (void)i_line;
397
398     /* Increase our wait count */
399     SignalObjectAndWait( *p_mutex, *p_condvar, INFINITE, FALSE );
400
401     /* Reacquire the mutex before returning. */
402     vlc_mutex_lock( p_mutex );
403
404 #elif defined( SYS_BEOS )
405     /* The p_condvar->thread var is initialized before the unlock because
406      * it enables to identify when the thread is interrupted beetwen the
407      * unlock line and the suspend_thread line */
408     p_condvar->thread = find_thread( NULL );
409     vlc_mutex_unlock( p_mutex );
410     suspend_thread( p_condvar->thread );
411     p_condvar->thread = -1;
412
413     vlc_mutex_lock( p_mutex );
414
415 #endif
416 }
417
418
419 /*****************************************************************************
420  * vlc_cond_timedwait: wait until condition completion or expiration
421  *****************************************************************************
422  * Returns 0 if object signaled, an error code in case of timeout or error.
423  *****************************************************************************/
424 #define vlc_cond_timedwait( P_COND, P_MUTEX, DEADLINE )                      \
425     __vlc_cond_timedwait( __FILE__, __LINE__, P_COND, P_MUTEX, DEADLINE  )
426
427 static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
428                                         vlc_cond_t *p_condvar,
429                                         vlc_mutex_t *p_mutex,
430                                         mtime_t deadline )
431 {
432 #if defined(LIBVLC_USE_PTHREAD)
433     lldiv_t d = lldiv( deadline, 1000000 );
434     struct timespec ts = { d.quot, d.rem * 1000 };
435
436     int val = pthread_cond_timedwait (p_condvar, p_mutex, &ts);
437     if (val == ETIMEDOUT)
438         return ETIMEDOUT; /* this error is perfectly normal */
439     VLC_THREAD_ASSERT ("timed-waiting on condition");
440
441 #elif defined( UNDER_CE )
442     mtime_t delay_ms = (deadline - mdate())/1000;
443     DWORD result;
444     if( delay_ms < 0 )
445         delay_ms = 0;
446
447     LeaveCriticalSection( &p_mutex->csection );
448     result = WaitForSingleObject( *p_condvar, delay_ms );
449
450     /* Reacquire the mutex before returning. */
451     vlc_mutex_lock( p_mutex );
452
453     if(result == WAIT_TIMEOUT)
454        return ETIMEDOUT; /* this error is perfectly normal */
455
456     (void)psz_file; (void)i_line;
457
458 #elif defined( WIN32 )
459     mtime_t total = (deadline - mdate())/1000;
460     DWORD result;
461     if( total < 0 )
462         total = 0;
463
464     do
465     {
466         DWORD delay = (total > 0x7fffffff) ? 0x7fffffff : total;
467         result = SignalObjectAndWait( *p_mutex, *p_condvar,
468                                       delay, FALSE );
469         total -= delay;
470         vlc_mutex_lock (p_mutex);
471     }
472     while (total);
473
474     /* Reacquire the mutex before returning. */
475     if(result == WAIT_TIMEOUT)
476        return ETIMEDOUT; /* this error is perfectly normal */
477
478     (void)psz_file; (void)i_line;
479
480 #elif defined( SYS_BEOS )
481 #   error Unimplemented
482
483 #endif
484
485     return 0;
486 }
487
488 /*****************************************************************************
489  * vlc_cond_destroy: destroy a condition
490  *****************************************************************************/
491 #define vlc_cond_destroy( P_COND )                                          \
492     __vlc_cond_destroy( __FILE__, __LINE__, P_COND )
493
494 /*****************************************************************************
495  * vlc_threadvar_set: create: set the value of a thread-local variable
496  *****************************************************************************/
497 static inline int vlc_threadvar_set( vlc_threadvar_t * p_tls, void *p_value )
498 {
499     int i_ret;
500
501 #if defined(LIBVLC_USE_PTHREAD)
502     i_ret = pthread_setspecific( *p_tls, p_value );
503
504 #elif defined( SYS_BEOS )
505     i_ret = EINVAL;
506
507 #elif defined( UNDER_CE ) || defined( WIN32 )
508     i_ret = TlsSetValue( *p_tls, p_value ) ? EINVAL : 0;
509
510 #endif
511
512     return i_ret;
513 }
514
515 /*****************************************************************************
516  * vlc_threadvar_get: create: get the value of a thread-local variable
517  *****************************************************************************/
518 static inline void* vlc_threadvar_get( vlc_threadvar_t * p_tls )
519 {
520     void *p_ret;
521
522 #if defined(LIBVLC_USE_PTHREAD)
523     p_ret = pthread_getspecific( *p_tls );
524
525 #elif defined( SYS_BEOS )
526     p_ret = NULL;
527
528 #elif defined( UNDER_CE ) || defined( WIN32 )
529     p_ret = TlsGetValue( *p_tls );
530
531 #endif
532
533     return p_ret;
534 }
535
536 # if defined (_POSIX_SPIN_LOCKS) && ((_POSIX_SPIN_LOCKS - 0) > 0)
537 typedef pthread_spinlock_t vlc_spinlock_t;
538
539 /**
540  * Initializes a spinlock.
541  */
542 static inline int vlc_spin_init (vlc_spinlock_t *spin)
543 {
544     return pthread_spin_init (spin, PTHREAD_PROCESS_PRIVATE);
545 }
546
547 /**
548  * Acquires a spinlock.
549  */
550 static inline void vlc_spin_lock (vlc_spinlock_t *spin)
551 {
552     pthread_spin_lock (spin);
553 }
554
555 /**
556  * Releases a spinlock.
557  */
558 static inline void vlc_spin_unlock (vlc_spinlock_t *spin)
559 {
560     pthread_spin_unlock (spin);
561 }
562
563 /**
564  * Deinitializes a spinlock.
565  */
566 static inline void vlc_spin_destroy (vlc_spinlock_t *spin)
567 {
568     pthread_spin_destroy (spin);
569 }
570
571 #elif defined( WIN32 )
572
573 typedef CRITICAL_SECTION vlc_spinlock_t;
574
575 /**
576  * Initializes a spinlock.
577  */
578 static inline int vlc_spin_init (vlc_spinlock_t *spin)
579 {
580     return !InitializeCriticalSectionAndSpinCount(spin, 4000);
581 }
582
583 /**
584  * Acquires a spinlock.
585  */
586 static inline void vlc_spin_lock (vlc_spinlock_t *spin)
587 {
588     EnterCriticalSection(spin);
589 }
590
591 /**
592  * Releases a spinlock.
593  */
594 static inline void vlc_spin_unlock (vlc_spinlock_t *spin)
595 {
596     LeaveCriticalSection(spin);
597 }
598
599 /**
600  * Deinitializes a spinlock.
601  */
602 static inline void vlc_spin_destroy (vlc_spinlock_t *spin)
603 {
604     DeleteCriticalSection(spin);
605 }
606
607 #else
608
609 /* Fallback to plain mutexes if spinlocks are not available */
610 typedef vlc_mutex_t vlc_spinlock_t;
611
612 static inline int vlc_spin_init (vlc_spinlock_t *spin)
613 {
614     return vlc_mutex_init (spin);
615 }
616
617 # define vlc_spin_lock    vlc_mutex_lock
618 # define vlc_spin_unlock  vlc_mutex_unlock
619 # define vlc_spin_destroy vlc_mutex_destroy
620 #endif
621
622 /**
623  * Issues a full memory barrier.
624  */
625 #if defined (__APPLE__)
626 # include <libkern/OSAtomic.h> /* OSMemoryBarrier() */
627 #endif
628 static inline void barrier (void)
629 {
630 #if defined (__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
631     __sync_synchronize ();
632 #elif defined(__APPLE__)
633     OSMemoryBarrier ();
634 #elif defined(__powerpc__)
635     asm volatile ("sync":::"memory");
636 #elif defined(__i386__)
637     asm volatile ("mfence":::"memory");
638 #else
639     vlc_spinlock_t spin;
640     vlc_spin_init (&spin);
641     vlc_spin_lock (&spin);
642     vlc_spin_unlock (&spin);
643     vlc_spin_destroy (&spin);
644 #endif
645 }
646
647 /*****************************************************************************
648  * vlc_thread_create: create a thread
649  *****************************************************************************/
650 #define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, PRIORITY, WAIT )         \
651     __vlc_thread_create( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, FUNC, PRIORITY, WAIT )
652
653 /*****************************************************************************
654  * vlc_thread_set_priority: set the priority of the calling thread
655  *****************************************************************************/
656 #define vlc_thread_set_priority( P_THIS, PRIORITY )                         \
657     __vlc_thread_set_priority( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PRIORITY )
658
659 /*****************************************************************************
660  * vlc_thread_join: wait until a thread exits
661  *****************************************************************************/
662 #define vlc_thread_join( P_THIS )                                           \
663     __vlc_thread_join( VLC_OBJECT(P_THIS), __FILE__, __LINE__ )
664
665 #endif /* !_VLC_THREADS_H */