*/
#if defined( UNDER_CE )
- /* WinCE API */
+# include <errno.h> /* WinCE API */
#elif defined( WIN32 )
# include <process.h> /* Win32 API */
# include <errno.h>
#if defined (LIBVLC_USE_PTHREAD)
typedef pthread_t vlc_thread_t;
typedef pthread_mutex_t vlc_mutex_t;
+#define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER
typedef pthread_cond_t vlc_cond_t;
typedef pthread_key_t vlc_threadvar_t;
HANDLE handle;
void *(*entry) (void *);
void *data;
+#if defined( UNDER_CE )
+ HANDLE cancel_event;
+#endif
} *vlc_thread_t;
typedef struct
{
CRITICAL_SECTION mutex;
- LONG owner;
- unsigned recursion;
- bool recursive;
-}
-vlc_mutex_t;
+ LONG initialized;
+} vlc_mutex_t;
+#define VLC_STATIC_MUTEX { .initialized = 0, }
+
typedef HANDLE vlc_cond_t;
typedef DWORD vlc_threadvar_t;
};
#endif
-#define vlc_thread_ready vlc_object_signal
+VLC_EXPORT(void, vlc_thread_ready, (vlc_object_t *obj));
+#define vlc_thread_ready(o) vlc_thread_ready(VLC_OBJECT(o))
/**
* Save the cancellation state and disable cancellation for the calling thread.
*/
static inline int vlc_spin_init (vlc_spinlock_t *spin)
{
+#ifdef UNDER_CE
+ InitializeCriticalSection(spin);
+ return 0;
+#else
return !InitializeCriticalSectionAndSpinCount(spin, 4000);
+#endif
}
/**
#define vlc_thread_join( P_THIS ) \
__vlc_thread_join( VLC_OBJECT(P_THIS) )
+#ifdef __cplusplus
+/**
+ * Helper C++ class to lock a mutex.
+ * The mutex is locked when the object is created, and unlocked when the object
+ * is destroyed.
+ */
+class vlc_mutex_locker
+{
+ private:
+ vlc_mutex_t *lock;
+ public:
+ vlc_mutex_locker (vlc_mutex_t *m) : lock (m)
+ {
+ vlc_mutex_lock (lock);
+ }
+
+ ~vlc_mutex_locker (void)
+ {
+ vlc_mutex_unlock (lock);
+ }
+};
+#endif
+
#endif /* !_VLC_THREADS_H */