]> git.sesse.net Git - vlc/blob - include/vlc_threads.h
Move stuff around
[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 };
190 #endif
191
192 #define vlc_thread_ready vlc_object_signal
193
194 /*****************************************************************************
195  * vlc_mutex_lock: lock a mutex
196  *****************************************************************************/
197 #define vlc_mutex_lock( P_MUTEX )                                           \
198     __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
199
200 VLC_EXPORT(void, vlc_pthread_fatal, (const char *action, int error, const char *file, unsigned line));
201
202 #if defined(LIBVLC_USE_PTHREAD)
203 # define VLC_THREAD_ASSERT( action ) \
204     if (val) \
205         vlc_pthread_fatal (action, val, psz_file, i_line)
206 #else
207 # define VLC_THREAD_ASSERT ((void)(val))
208 #endif
209
210 static inline void __vlc_mutex_lock( const char * psz_file, int i_line,
211                                     vlc_mutex_t * p_mutex )
212 {
213 #if defined(LIBVLC_USE_PTHREAD)
214 #   define vlc_assert_locked( m ) \
215            assert (pthread_mutex_lock (m) == EDEADLK)
216     int val = pthread_mutex_lock( p_mutex );
217     VLC_THREAD_ASSERT ("locking mutex");
218
219 #elif defined( UNDER_CE )
220     (void)psz_file; (void)i_line;
221
222     EnterCriticalSection( &p_mutex->csection );
223
224 #elif defined( WIN32 )
225     (void)psz_file; (void)i_line;
226
227     WaitForSingleObject( *p_mutex, INFINITE );
228
229 #elif defined( SYS_BEOS )
230     acquire_sem( p_mutex->lock );
231
232 #endif
233 }
234
235 #ifndef vlc_assert_locked
236 # define vlc_assert_locked( m ) (void)m
237 #endif
238
239 /*****************************************************************************
240  * vlc_mutex_unlock: unlock a mutex
241  *****************************************************************************/
242 #define vlc_mutex_unlock( P_MUTEX )                                         \
243     __vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
244
245 static inline void __vlc_mutex_unlock( const char * psz_file, int i_line,
246                                       vlc_mutex_t *p_mutex )
247 {
248 #if defined(LIBVLC_USE_PTHREAD)
249     int val = pthread_mutex_unlock( p_mutex );
250     VLC_THREAD_ASSERT ("unlocking mutex");
251
252 #elif defined( UNDER_CE )
253     (void)psz_file; (void)i_line;
254
255     LeaveCriticalSection( &p_mutex->csection );
256
257 #elif defined( WIN32 )
258     (void)psz_file; (void)i_line;
259
260     ReleaseMutex( *p_mutex );
261
262 #elif defined( SYS_BEOS )
263     release_sem( p_mutex->lock );
264
265 #endif
266 }
267
268 /*****************************************************************************
269  * vlc_mutex_destroy: destroy a mutex
270  *****************************************************************************/
271 #define vlc_mutex_destroy( P_MUTEX )                                        \
272     __vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
273
274 /**
275  * Save the cancellation state and disable cancellation for the calling thread.
276  * This function must be called before entering a piece of code that is not
277  * cancellation-safe.
278  * @return Previous cancellation state (opaque value).
279  */
280 static inline int vlc_savecancel (void)
281 {
282     int state;
283 #if defined (LIBVLC_USE_PTHREAD)
284     (void) pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
285 #else
286     vlc_control_cancel (VLC_SAVE_CANCEL, &state);
287 #endif
288     return state;
289 }
290
291 /**
292  * Restore the cancellation state for the calling thread.
293  * @param state previous state as returned by vlc_savecancel().
294  * @return Nothing, always succeeds.
295  */
296 static inline void vlc_restorecancel (int state)
297 {
298 #if defined (LIBVLC_USE_PTHREAD)
299     (void) pthread_setcancelstate (state, NULL);
300 #else
301     vlc_control_cancel (VLC_RESTORE_CANCEL, state);
302 #endif
303 }
304
305 /**
306  * Issues an explicit deferred cancellation point.
307  * This has no effect if thread cancellation is disabled.
308  * This can be called when there is a rather slow non-sleeping operation.
309  */
310 static inline void vlc_testcancel (void)
311 {
312 #if defined (LIBVLC_USE_PTHREAD)
313     pthread_testcancel ();
314 #else
315     vlc_control_cancel (VLC_TEST_CANCEL);
316 #endif
317 }
318
319 /*****************************************************************************
320  * vlc_cond_init: initialize a condition
321  *****************************************************************************/
322 #define vlc_cond_init( P_THIS, P_COND )                                     \
323     __vlc_cond_init( P_COND )
324
325 /*****************************************************************************
326  * vlc_cond_signal: start a thread on condition completion
327  *****************************************************************************/
328 #define vlc_cond_signal( P_COND )                                           \
329     __vlc_cond_signal( __FILE__, __LINE__, P_COND )
330
331 static inline void __vlc_cond_signal( const char * psz_file, int i_line,
332                                       vlc_cond_t *p_condvar )
333 {
334 #if defined(LIBVLC_USE_PTHREAD)
335     int val = pthread_cond_signal( p_condvar );
336     VLC_THREAD_ASSERT ("signaling condition variable");
337
338 #elif defined( UNDER_CE ) || defined( WIN32 )
339     (void)psz_file; (void)i_line;
340
341     /* Release one waiting thread if one is available. */
342     /* For this trick to work properly, the vlc_cond_signal must be surrounded
343      * by a mutex. This will prevent another thread from stealing the signal */
344     /* PulseEvent() only works if none of the waiting threads is suspended.
345      * This is particularily problematic under a debug session.
346      * as documented in http://support.microsoft.com/kb/q173260/ */
347     PulseEvent( *p_condvar );
348
349 #elif defined( SYS_BEOS )
350     while( p_condvar->thread != -1 )
351     {
352         thread_info info;
353         if( get_thread_info(p_condvar->thread, &info) == B_BAD_VALUE )
354             return;
355
356         if( info.state != B_THREAD_SUSPENDED )
357         {
358             /* The  waiting thread is not suspended so it could
359              * have been interrupted beetwen the unlock and the
360              * suspend_thread line. That is why we sleep a little
361              * before retesting p_condver->thread. */
362             snooze( 10000 );
363         }
364         else
365         {
366             /* Ok, we have to wake up that thread */
367             resume_thread( p_condvar->thread );
368         }
369     }
370
371 #endif
372 }
373
374 /*****************************************************************************
375  * vlc_cond_wait: wait until condition completion
376  *****************************************************************************/
377 #define vlc_cond_wait( P_COND, P_MUTEX )                                     \
378     __vlc_cond_wait( __FILE__, __LINE__, P_COND, P_MUTEX  )
379
380 static inline void __vlc_cond_wait( const char * psz_file, int i_line,
381                                     vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
382 {
383 #if defined(LIBVLC_USE_PTHREAD)
384     int val = pthread_cond_wait( p_condvar, p_mutex );
385     VLC_THREAD_ASSERT ("waiting on condition");
386
387 #elif defined( UNDER_CE )
388     LeaveCriticalSection( &p_mutex->csection );
389     WaitForSingleObject( *p_condvar, INFINITE );
390
391     /* Reacquire the mutex before returning. */
392     vlc_mutex_lock( p_mutex );
393
394 #elif defined( WIN32 )
395     (void)psz_file; (void)i_line;
396
397     /* Increase our wait count */
398     SignalObjectAndWait( *p_mutex, *p_condvar, INFINITE, FALSE );
399
400     /* Reacquire the mutex before returning. */
401     vlc_mutex_lock( p_mutex );
402
403 #elif defined( SYS_BEOS )
404     /* The p_condvar->thread var is initialized before the unlock because
405      * it enables to identify when the thread is interrupted beetwen the
406      * unlock line and the suspend_thread line */
407     p_condvar->thread = find_thread( NULL );
408     vlc_mutex_unlock( p_mutex );
409     suspend_thread( p_condvar->thread );
410     p_condvar->thread = -1;
411
412     vlc_mutex_lock( p_mutex );
413
414 #endif
415 }
416
417
418 /*****************************************************************************
419  * vlc_cond_timedwait: wait until condition completion or expiration
420  *****************************************************************************
421  * Returns 0 if object signaled, an error code in case of timeout or error.
422  *****************************************************************************/
423 #define vlc_cond_timedwait( P_COND, P_MUTEX, DEADLINE )                      \
424     __vlc_cond_timedwait( __FILE__, __LINE__, P_COND, P_MUTEX, DEADLINE  )
425
426 static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
427                                         vlc_cond_t *p_condvar,
428                                         vlc_mutex_t *p_mutex,
429                                         mtime_t deadline )
430 {
431 #if defined(LIBVLC_USE_PTHREAD)
432     lldiv_t d = lldiv( deadline, 1000000 );
433     struct timespec ts = { d.quot, d.rem * 1000 };
434
435     int val = pthread_cond_timedwait (p_condvar, p_mutex, &ts);
436     if (val == ETIMEDOUT)
437         return ETIMEDOUT; /* this error is perfectly normal */
438     VLC_THREAD_ASSERT ("timed-waiting on condition");
439
440 #elif defined( UNDER_CE )
441     mtime_t delay_ms = (deadline - mdate())/1000;
442     DWORD result;
443     if( delay_ms < 0 )
444         delay_ms = 0;
445
446     LeaveCriticalSection( &p_mutex->csection );
447     result = WaitForSingleObject( *p_condvar, delay_ms );
448
449     /* Reacquire the mutex before returning. */
450     vlc_mutex_lock( p_mutex );
451
452     if(result == WAIT_TIMEOUT)
453        return ETIMEDOUT; /* this error is perfectly normal */
454
455     (void)psz_file; (void)i_line;
456
457 #elif defined( WIN32 )
458     mtime_t total = (deadline - mdate())/1000;
459     DWORD result;
460     if( total < 0 )
461         total = 0;
462
463     do
464     {
465         DWORD delay = (total > 0x7fffffff) ? 0x7fffffff : total;
466         result = SignalObjectAndWait( *p_mutex, *p_condvar,
467                                       delay, FALSE );
468         total -= delay;
469         vlc_mutex_lock (p_mutex);
470     }
471     while (total);
472
473     /* Reacquire the mutex before returning. */
474     if(result == WAIT_TIMEOUT)
475        return ETIMEDOUT; /* this error is perfectly normal */
476
477     (void)psz_file; (void)i_line;
478
479 #elif defined( SYS_BEOS )
480 #   error Unimplemented
481
482 #endif
483
484     return 0;
485 }
486
487 /*****************************************************************************
488  * vlc_cond_destroy: destroy a condition
489  *****************************************************************************/
490 #define vlc_cond_destroy( P_COND )                                          \
491     __vlc_cond_destroy( __FILE__, __LINE__, P_COND )
492
493 /*****************************************************************************
494  * vlc_threadvar_set: create: set the value of a thread-local variable
495  *****************************************************************************/
496 static inline int vlc_threadvar_set( vlc_threadvar_t * p_tls, void *p_value )
497 {
498     int i_ret;
499
500 #if defined(LIBVLC_USE_PTHREAD)
501     i_ret = pthread_setspecific( *p_tls, p_value );
502
503 #elif defined( SYS_BEOS )
504     i_ret = EINVAL;
505
506 #elif defined( UNDER_CE ) || defined( WIN32 )
507     i_ret = TlsSetValue( *p_tls, p_value ) ? EINVAL : 0;
508
509 #endif
510
511     return i_ret;
512 }
513
514 /*****************************************************************************
515  * vlc_threadvar_get: create: get the value of a thread-local variable
516  *****************************************************************************/
517 static inline void* vlc_threadvar_get( vlc_threadvar_t * p_tls )
518 {
519     void *p_ret;
520
521 #if defined(LIBVLC_USE_PTHREAD)
522     p_ret = pthread_getspecific( *p_tls );
523
524 #elif defined( SYS_BEOS )
525     p_ret = NULL;
526
527 #elif defined( UNDER_CE ) || defined( WIN32 )
528     p_ret = TlsGetValue( *p_tls );
529
530 #endif
531
532     return p_ret;
533 }
534
535 # if defined (_POSIX_SPIN_LOCKS) && ((_POSIX_SPIN_LOCKS - 0) > 0)
536 typedef pthread_spinlock_t vlc_spinlock_t;
537
538 /**
539  * Initializes a spinlock.
540  */
541 static inline int vlc_spin_init (vlc_spinlock_t *spin)
542 {
543     return pthread_spin_init (spin, PTHREAD_PROCESS_PRIVATE);
544 }
545
546 /**
547  * Acquires a spinlock.
548  */
549 static inline void vlc_spin_lock (vlc_spinlock_t *spin)
550 {
551     pthread_spin_lock (spin);
552 }
553
554 /**
555  * Releases a spinlock.
556  */
557 static inline void vlc_spin_unlock (vlc_spinlock_t *spin)
558 {
559     pthread_spin_unlock (spin);
560 }
561
562 /**
563  * Deinitializes a spinlock.
564  */
565 static inline void vlc_spin_destroy (vlc_spinlock_t *spin)
566 {
567     pthread_spin_destroy (spin);
568 }
569
570 #elif defined( WIN32 )
571
572 typedef CRITICAL_SECTION vlc_spinlock_t;
573
574 /**
575  * Initializes a spinlock.
576  */
577 static inline int vlc_spin_init (vlc_spinlock_t *spin)
578 {
579     return !InitializeCriticalSectionAndSpinCount(spin, 4000);
580 }
581
582 /**
583  * Acquires a spinlock.
584  */
585 static inline void vlc_spin_lock (vlc_spinlock_t *spin)
586 {
587     EnterCriticalSection(spin);
588 }
589
590 /**
591  * Releases a spinlock.
592  */
593 static inline void vlc_spin_unlock (vlc_spinlock_t *spin)
594 {
595     LeaveCriticalSection(spin);
596 }
597
598 /**
599  * Deinitializes a spinlock.
600  */
601 static inline void vlc_spin_destroy (vlc_spinlock_t *spin)
602 {
603     DeleteCriticalSection(spin);
604 }
605
606 #else
607
608 /* Fallback to plain mutexes if spinlocks are not available */
609 typedef vlc_mutex_t vlc_spinlock_t;
610
611 static inline int vlc_spin_init (vlc_spinlock_t *spin)
612 {
613     return vlc_mutex_init (spin);
614 }
615
616 # define vlc_spin_lock    vlc_mutex_lock
617 # define vlc_spin_unlock  vlc_mutex_unlock
618 # define vlc_spin_destroy vlc_mutex_destroy
619 #endif
620
621 /**
622  * Issues a full memory barrier.
623  */
624 #if defined (__APPLE__)
625 # include <libkern/OSAtomic.h> /* OSMemoryBarrier() */
626 #endif
627 static inline void barrier (void)
628 {
629 #if defined (__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
630     __sync_synchronize ();
631 #elif defined(__APPLE__)
632     OSMemoryBarrier ();
633 #elif defined(__powerpc__)
634     asm volatile ("sync":::"memory");
635 #elif defined(__i386__)
636     asm volatile ("mfence":::"memory");
637 #else
638     vlc_spinlock_t spin;
639     vlc_spin_init (&spin);
640     vlc_spin_lock (&spin);
641     vlc_spin_unlock (&spin);
642     vlc_spin_destroy (&spin);
643 #endif
644 }
645
646 /*****************************************************************************
647  * vlc_thread_create: create a thread
648  *****************************************************************************/
649 #define vlc_thread_create( P_THIS, PSZ_NAME, FUNC, PRIORITY, WAIT )         \
650     __vlc_thread_create( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PSZ_NAME, FUNC, PRIORITY, WAIT )
651
652 /*****************************************************************************
653  * vlc_thread_set_priority: set the priority of the calling thread
654  *****************************************************************************/
655 #define vlc_thread_set_priority( P_THIS, PRIORITY )                         \
656     __vlc_thread_set_priority( VLC_OBJECT(P_THIS), __FILE__, __LINE__, PRIORITY )
657
658 /*****************************************************************************
659  * vlc_thread_join: wait until a thread exits
660  *****************************************************************************/
661 #define vlc_thread_join( P_THIS )                                           \
662     __vlc_thread_join( VLC_OBJECT(P_THIS), __FILE__, __LINE__ )
663
664 #endif /* !_VLC_THREADS_H */