38 #ifndef _DN_EXP_THREAD 39 #define _DN_EXP_THREAD 62 #if defined(_USE_WIN_API) 63 #define begin_thread(p_thread, function, arg) { *p_thread = (HANDLE)_beginthreadex(NULL, 0, function, arg, 0, NULL); } 64 #define exit_thread(thread) { if(thread != NULL) { WaitForSingleObject(thread, INFINITE); CloseHandle(thread); thread = NULL; } } 65 #define dn_sleep(n) Sleep(n) 68 typedef unsigned int THRET;
69 #define THTYPE __stdcall 71 #elif defined(_USE_LINUX_API) 72 #define begin_thread(p_thread, function, arg) pthread_create(p_thread, NULL, function, arg) 73 #define exit_thread(thread) pthread_join(thread, NULL) 74 #define dn_sleep(n) usleep((n) * 1000) 75 typedef pthread_mutex_t
MUTEX;
79 #define STATUS_WAIT_0 ((uint32_t)0x00000000L) 80 #define WAIT_OBJECT_0 ((STATUS_WAIT_0) + 0) 83 pthread_mutex_t mutex;
95 #define INFINITE ((uint32_t)-1) 199 #define calc_time_diff(start, end) (((end) >= (start)) ? ((end) - (start)) : ((((uint32_t)-1) - (end)) + (start))) _DN_EXP_THREAD HRESULT wait_event(EVENT *pevt, uint32_t timeout)
Waits a event.
_DN_EXP_THREAD HRESULT unlock_mutex(MUTEX *pmutex)
Unlocks mutex handle.
_DN_EXP_THREAD HRESULT lock_mutex(MUTEX *pmutex, uint32_t timeout)
Locks mutex handle.
_DN_EXP_THREAD HRESULT create_event(EVENT *pevt, int reset_mode, int init_signal)
Creates a event object.
_DN_EXP_THREAD HRESULT wait_event_multi(EVENT **pevt, uint32_t count, uint32_t timeout, int wait_all)
Waits multiple events.
_DN_EXP_THREAD HRESULT destroy_event(EVENT *pevt)
Destroys a event object.
_DN_EXP_THREAD HRESULT set_event(EVENT *pevt)
Sets a event.
_DN_EXP_THREAD uint32_t gettimeofday_msec()
Gets the current time value [ms].
_DN_EXP_THREAD HRESULT release_mutex(MUTEX *pmutex)
Releases mutex handle.
_DN_EXP_THREAD HRESULT initialize_mutex(MUTEX *pmutex)
Initializes mutex handle.
_DN_EXP_THREAD HRESULT reset_event(EVENT *pevt)
Resets a event.