Changeset 651078ecf9be6d0bb9c2323023ebb7fbd7f0d145
- Timestamp:
- 12/18/06 22:40:12 (2 years ago)
- git-parent:
- Files:
-
- include/vlc_threads.h (modified) (6 diffs)
- include/vlc_threads_funcs.h (modified) (2 diffs)
- src/misc/threads.c (modified) (1 diff)
- test/NativeLibvlcTest.py (modified) (1 diff)
- test/native/init.c (modified) (1 diff)
- test/native/tests.h (modified) (1 diff)
- test/native/threads.c (added)
- test/setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_threads.h
rfbf4c80 r651078e 140 140 vlc_object_t * p_this; 141 141 } vlc_cond_t; 142 typedef struct 143 { 144 } vlc_threadvar_t; 142 145 143 146 #elif defined( ST_INIT_IN_ST_H ) … … 153 156 vlc_object_t * p_this; 154 157 } vlc_cond_t; 158 typedef struct 159 { 160 } vlc_threadvar_t; 155 161 156 162 #elif defined( WIN32 ) || defined( UNDER_CE ) … … 183 189 } vlc_cond_t; 184 190 191 typedef struct 192 { 193 DWORD handle; 194 } vlc_threadvar_t; 195 185 196 #elif defined( HAVE_KERNEL_SCHEDULER_H ) 186 197 /* This is the BeOS implementation of the vlc threads, note that the mutex is … … 206 217 } vlc_cond_t; 207 218 219 typedef struct 220 { 221 } vlc_threadvar_t; 222 223 208 224 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) 209 225 typedef pthread_t vlc_thread_t; … … 218 234 vlc_object_t * p_this; 219 235 } vlc_cond_t; 236 237 typedef struct 238 { 239 pthread_key_t handle; 240 } vlc_threadvar_t; 220 241 221 242 #elif defined( HAVE_CTHREADS_H ) … … 245 266 } vlc_cond_t; 246 267 247 #endif 248 268 typedef struct 269 { 270 cthread_key_t handle; 271 } vlc_threadvar_t; 272 273 #endif 274 include/vlc_threads_funcs.h
r4475aed r651078e 39 39 VLC_EXPORT( int, __vlc_cond_init, ( vlc_object_t *, vlc_cond_t * ) ); 40 40 VLC_EXPORT( int, __vlc_cond_destroy, ( const char *, int, vlc_cond_t * ) ); 41 VLC_EXPORT( int, __vlc_threadvar_create, (vlc_object_t *, vlc_threadvar_t * ) ); 41 42 VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( void * ), int, vlc_bool_t ) ); 42 43 VLC_EXPORT( int, __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) ); … … 549 550 550 551 /***************************************************************************** 552 * vlc_threadvar_create: create a thread-local variable 553 *****************************************************************************/ 554 #define vlc_threadvar_create( PTHIS, P_TLS ) \ 555 __vlc_threadvar_create( PTHIS, P_TLS ) 556 557 /***************************************************************************** 558 * vlc_threadvar_set: create: set the value of a thread-local variable 559 *****************************************************************************/ 560 #define vlc_threadvar_set( P_TLS , P_VAL ) \ 561 __vlc_threadvar_set( __FILE__, __LINE__, P_TLS, P_VAL ) 562 563 static inline int __vlc_threadvar_set( char* psz_file, int line, 564 vlc_threadvar_t * p_tls, void *p_value ) 565 { 566 int i_ret; 567 568 #if defined( PTH_INIT_IN_PTH_H ) || \ 569 defined( ST_INIT_IN_ST_H ) || defined( HAVE_KERNEL_SCHEDULER_H ) 570 return -1; 571 572 #elif defined( UNDER_CE ) || defined( WIN32 ) 573 i_ret = ( TlsSetValue( &p_tls->handle, p_value ) != 0 ); 574 575 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) 576 i_ret = pthread_setspecific( p_tls->handle, p_value ); 577 578 #elif defined( HAVE_CTHREADS_H ) 579 i_ret = cthread_setspecific( p_tls->handle, p_value ); 580 #endif 581 582 return i_ret; 583 } 584 585 /***************************************************************************** 586 * vlc_threadvar_get: create: get the value of a thread-local variable 587 *****************************************************************************/ 588 #define vlc_threadvar_get( P_TLS ) \ 589 __vlc_threadvar_get( __FILE__, __LINE__, P_TLS ) 590 591 static inline void* __vlc_threadvar_get( char* psz_file, int line, 592 vlc_threadvar_t * p_tls ) 593 { 594 void* p_ret; 595 596 #if defined( PTH_INIT_IN_PTH_H ) || \ 597 defined( ST_INIT_IN_ST_H ) || defined( HAVE_KERNEL_SCHEDULER_H ) 598 return NULL; 599 600 #elif defined( UNDER_CE ) || defined( WIN32 ) 601 p_ret = TlsGetValue( &p_tls->handle ); 602 603 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) 604 p_ret = pthread_getspecific( p_tls->handle ); 605 606 #elif defined( HAVE_CTHREADS_H ) 607 if ( !cthread_getspecific( p_tls->handle, &p_ret ) ) 608 { 609 p_ret = NULL; 610 } 611 #endif 612 613 return p_ret; 614 } 615 616 /***************************************************************************** 551 617 * vlc_thread_create: create a thread 552 618 *****************************************************************************/ src/misc/threads.c
r1e4db90 r651078e 502 502 503 503 /***************************************************************************** 504 * vlc_tls_create: create a thread-local variable 505 *****************************************************************************/ 506 int __vlc_threadvar_create( vlc_object_t *p_this, vlc_threadvar_t *p_tls ) 507 { 508 #if defined( PTH_INIT_IN_PTH_H ) 509 #elif defined( HAVE_KERNEL_SCHEDULER_H ) 510 #elif defined( ST_INIT_IN_ST_H ) 511 msg_Err( p_this, "TLS not implemented" ); 512 return VLC_EGENERIC; 513 514 #elif defined( UNDER_CE ) || defined( WIN32 ) 515 #elif defined( WIN32 ) 516 p_tls->handle = TlsAlloc(); 517 if( p_tls->handle == 0xFFFFFFFF ) 518 { 519 return VLC_EGENERIC; 520 } 521 522 msg_Err( p_this, "TLS not implemented" ); 523 return VLC_EGENERIC; 524 525 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) 526 return pthread_key_create( &p_tls->handle, NULL ); 527 528 #elif defined( HAVE_CTHREADS_H ) 529 return cthread_keycreate( &p_tls-handle ); 530 #endif 531 } 532 533 /***************************************************************************** 504 534 * vlc_thread_create: create a thread, inner version 505 535 ***************************************************************************** test/NativeLibvlcTest.py
racf462d r651078e 4 4 5 5 class NativeLibvlcTestCase( unittest.TestCase ): 6 def testTls( self ): 7 """[Thread] Set TLS""" 8 native_libvlc_test.threadvar_test() 6 9 def test1Exception( self ): 7 10 """[LibVLC] Checks libvlc_exception""" test/native/init.c
r266fb28 r651078e 25 25 DEF_METHOD( bsearch_member_test, "Test Bsearch with structure" ) 26 26 DEF_METHOD( dict_test, "Test dictionnaries" ) 27 DEF_METHOD( threadvar_test, "Test TLS" ) 27 28 { NULL, NULL, 0, NULL } 28 29 }; test/native/tests.h
r266fb28 r651078e 6 6 PyObject *playlist_test( PyObject *self, PyObject *args ); 7 7 PyObject *vlm_test( PyObject *self, PyObject *args ); 8 9 PyObject *threadvar_test( PyObject *self, PyObject *args ); 8 10 9 11 /* Stats */ test/setup.py
racf462d r651078e 43 43 sources = ['native/init.c', 'native/url.c', 'native/i18n.c', 44 44 'native/stats.c', 'native/libvlc.c', 'native/profiles.c', 45 'native/algo.c' ],45 'native/algo.c', 'native/threads.c'], 46 46 include_dirs = ['../include', '../', '/usr/win32/include' ], 47 47 extra_objects = [ '../src/.libs/libvlc.so', '../src/.libs/libvlc-control.so' ],
