代码拉取完成,页面将自动刷新
#ifndef __THREAD_H__
#define __THREAD_H__
#ifdef __cplusplus
extern "C" {
#endif
#define OPER_OK 0
#define THREAD_MUTEX_INIT_ERROR -1
#define MUTEX_DESTROY_ERROR -2
#define THREAD_MUTEX_LOCK_ERROR -3
#define THREAD_MUTEX_UNLOCK_ERROR -4
#define THREAD_COND_INIT_ERROR -5
#define COND_DESTROY_ERROR -6
#define COND_SIGNAL_ERROR -7
#define COND_WAIT_ERROR -8
/* Define to prevent recursive inclusion
-------------------------------------*/
#include <pthread.h>
#include<sys/types.h>
#include <time.h>
typedef struct _mutex
{
pthread_mutex_t mutex;
}mutex_t;
typedef struct _cond
{
pthread_cond_t cond;
}cond_t;
typedef pthread_t tid_t;
typedef pthread_attr_t attr_t;
typedef void* (* thread_fun_t)(void*);
typedef struct _thread
{
tid_t tid;
cond_t *cv;
int32_t state;
int32_t stack_size;
attr_t attr;
thread_fun_t fun;
}thread_t;
/* mutex */
extern int32_t mutex_init(mutex_t *m);
extern int32_t mutex_destroy(mutex_t *m);
extern int32_t mutex_lock(mutex_t *m);
extern int32_t mutex_unlock(mutex_t *m);
/* cond */
extern int32_t cond_init(cond_t *c);
extern int32_t cond_destroy(cond_t *c);
extern int32_t cond_signal(cond_t *c);
extern int32_t cond_wait(cond_t *c,mutex_t *m);
//extern int32_t cond_timed_wait(cond_t *c,mutex_t *m,struct timespec* time);
/* thread */
/* 线程的创建,其属性的设置等都封装在里面 */
extern int32_t thread_create(thread_t *t);
//extern int32_t thread_init(thread_t *t);
#define thread_join(t, p) pthread_join(t, p)
#define thread_self() pthread_self()
#define thread_sigmask pthread_sigmask
#ifdef __cplusplus
}
#endif
#endif
/* END OF FILE
---------------------------------------------------------------*/
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。