* This header provides a portable threads implementation.
*****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN
- * $Id: vlc_threads_funcs.h,v 1.5 2002/10/04 18:07:21 sam Exp $
+ * $Id: vlc_threads_funcs.h,v 1.9 2002/11/11 14:39:11 sam Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
VLC_EXPORT( void, __vlc_thread_ready, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, char *, int ) );
-VLC_EXPORT( vlc_mutex_t *, __vlc_mutex_need, ( vlc_object_t *, char * ) );
-VLC_EXPORT( void , __vlc_mutex_unneed, ( vlc_object_t *, char * ) );
-
/*****************************************************************************
* vlc_threads_init: initialize threads system
*****************************************************************************/
#define vlc_mutex_init( P_THIS, P_MUTEX ) \
__vlc_mutex_init( VLC_OBJECT(P_THIS), P_MUTEX )
-/*****************************************************************************
- * vlc_mutex_need: create a global mutex from its name
- *****************************************************************************/
-#define vlc_mutex_need( P_THIS, P_NAME ) \
- __vlc_mutex_need( VLC_OBJECT(P_THIS), P_NAME )
-
/*****************************************************************************
* vlc_mutex_lock: lock a mutex
*****************************************************************************/
#elif defined( ST_INIT_IN_ST_H )
i_result = st_mutex_lock( p_mutex->mutex );
+#elif defined( UNDER_CE )
+ EnterCriticalSection( &p_mutex->csection );
+ return 0;
+
#elif defined( WIN32 )
if( p_mutex->mutex )
{
#elif defined( ST_INIT_IN_ST_H )
i_result = st_mutex_unlock( p_mutex->mutex );
+#elif defined( UNDER_CE )
+ LeaveCriticalSection( &p_mutex->csection );
+ return 0;
+
#elif defined( WIN32 )
if( p_mutex->mutex )
{
return i_result;
}
-/*****************************************************************************
- * vlc_mutex_unneed: destroycreate a global mutex from its name
- *****************************************************************************/
-#define vlc_mutex_unneed( P_THIS, P_NAME ) \
- __vlc_mutex_unneed( VLC_OBJECT(P_THIS), P_NAME )
-
/*****************************************************************************
* vlc_mutex_destroy: destroy a mutex
*****************************************************************************/
#elif defined( ST_INIT_IN_ST_H )
i_result = st_cond_signal( p_condvar->cond );
+#elif defined( UNDER_CE )
+ PulseEvent( p_condvar->event );
+ return 0;
+
#elif defined( WIN32 )
/* Release one waiting thread if one is available. */
/* For this trick to work properly, the vlc_cond_signal must be surrounded
return 0;
}
}
+ i_result = 0;
}
#endif
#elif defined( ST_INIT_IN_ST_H )
i_result = st_cond_broadcast( p_condvar->cond );
+#elif defined( UNDER_CE )
+ int i;
+
+ /* Release all waiting threads. */
+ for( i = p_condvar->i_waiting_threads; i > 0; i-- )
+ {
+ PulseEvent( p_condvar->event );
+ }
+ return 0;
+
#elif defined( WIN32 )
int i;
return 0;
}
}
+ i_result = 0;
}
#endif
i_result = st_cond_wait( p_condvar->cond );
st_mutex_lock( p_mutex->mutex );
+#elif defined( UNDER_CE )
+ p_condvar->i_waiting_threads++;
+ LeaveCriticalSection( &p_mutex->csection );
+ WaitForSingleObject( p_condvar->event, INFINITE );
+ p_condvar->i_waiting_threads--;
+
+ /* Reacquire the mutex before returning. */
+ vlc_mutex_lock( p_mutex );
+
+ return 0;
+
#elif defined( WIN32 )
if( !p_condvar->semaphore )
{