CMCore/inc/hgl/platform/os/PosixThread.h

29 lines
635 B
C
Raw Normal View History

2019-08-19 19:19:58 +08:00
#ifndef HGL_POSIX_THREAD_INCLUDE
#define HGL_POSIX_THREAD_INCLUDE
#include<pthread.h>
2019-12-10 14:38:29 +08:00
#ifdef __APPLE__
#include<dispatch/dispatch.h>
#endif//__APPLE__
2019-08-19 19:19:58 +08:00
namespace hgl
{
using hgl_thread_mutex =pthread_mutex_t;
using thread_ptr =pthread_t;
2019-12-10 14:38:29 +08:00
using rwlock_ptr =pthread_rwlock_t *;
#ifdef __APPLE__
using semaphore_ptr =dispatch_semaphore_t *;
#else
using semaphore_ptr =sem_t *;
#endif//
using cond_var_ptr =pthread_cond_t *;
2019-08-19 19:19:58 +08:00
2019-12-10 14:38:29 +08:00
#define THREAD_FUNC void *
2019-08-19 19:19:58 +08:00
#define HGL_THREAD_DETACH_SELF pthread_detach(pthread_self());
}//namespace hgl
#endif//HGL_POSIX_THREAD_INCLUDE