thread.h

来自「FinC编译器源代码」· C头文件 代码 · 共 66 行

H
66
字号
#ifndef _THREAD_H_#define _THREAD_H_#include <tiny/global.h>#include <tiny/string.h>/*if support thread.*/#ifdef HAVE_THREADtypedef void (*ThreadFunc) (ADT data);typedef struct _Thread Thread;typedef struct _Mutex Mutex;typedef struct _Cond Cond;struct _Thread{	Object parent;	ADT thread;	ADT data;	ThreadFunc func;	Bool joinable;};Thread* thread_new(ThreadFunc func, ADT data, Bool joinable, Bool bound);void thread_destroy(Object* self);void thread_cancel(Thread* other);void thread_join(Thread* ohter);void thread_self(Thread* other);void thread_testcancel();void thread_exit();struct _Mutex{	Object parent;	ADT* mutex;};Mutex* mutex_new();void mutex_destroy(Object* self);void mutex_lock(Mutex* self);void mutex_unlock(Mutex* self);Bool mutex_try_lock(Mutex* self);#define lock(mutex)		mutex_lock(mutex)#define unlock(mutex)	mutex_unlock(mutex)struct _Cond{	Object parent;	ADT* cond;};Cond* cond_new();void  cond_destroy(Object* self);void  cond_signal(Cond* self);void  cond_wait(Cond* self, Mutex* mutex);Bool  cond_timewait(Cond* self, Mutex* mutex);void  cond_broadcast(Cond* self);#endif#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?