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

32 lines
692 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>
2020-01-23 20:37:42 +08:00
#include<semaphore.h>
2019-08-19 19:19:58 +08:00
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
{
2019-12-10 15:05:56 +08:00
using thread_mutex_ptr =pthread_mutex_t;
2019-08-19 19:19:58 +08:00
using thread_ptr =pthread_t;
2020-01-23 20:37:42 +08:00
using rwlock_ptr =pthread_rwlock_t;
2019-12-10 14:38:29 +08:00
#ifdef __APPLE__
using semaphore_ptr =dispatch_semaphore_t *;
#else
2020-02-08 15:03:07 +08:00
using semaphore_ptr =sem_t *;
2019-12-10 14:38:29 +08:00
#endif//
2020-01-23 20:37:42 +08:00
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());
2019-12-10 15:05:56 +08:00
2020-02-08 15:03:07 +08:00
using proc_mutex_ptr =sem_t *;
2019-08-19 19:19:58 +08:00
}//namespace hgl
#endif//HGL_POSIX_THREAD_INCLUDE