added:
* threads support with mutexes
This commit is contained in:
parent
59b55c7f6c
commit
bb6f3f967c
5 changed files with 248 additions and 31 deletions
42
cthreads.h
Normal file
42
cthreads.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// == THREAD ===========================================
|
||||
|
||||
typedef uintptr_t cthread_t;
|
||||
|
||||
typedef int (*cthread_func_t)(void *);
|
||||
|
||||
cthread_t thrCreate(cthread_func_t func, void *arg);
|
||||
bool thrValid(cthread_t ctx);
|
||||
bool thrDetach(cthread_t ctx);
|
||||
|
||||
cthread_t thrCurrent(void);
|
||||
int thrCurrentId(void);
|
||||
int thrGetId(cthread_t ctx);
|
||||
|
||||
void thrExit(int code);
|
||||
bool thrJoin(cthread_t ctx, int *code);
|
||||
|
||||
// == MUTEX ============================================
|
||||
|
||||
typedef uintptr_t cmutex_t;
|
||||
|
||||
cmutex_t mtxInit(void);
|
||||
void mtxDestroy(cmutex_t ctx);
|
||||
|
||||
bool mtxValid(cmutex_t ctx);
|
||||
|
||||
bool mtxLock(cmutex_t ctx);
|
||||
bool mtxTryLock(cmutex_t ctx);
|
||||
bool mtxUnlock(cmutex_t ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue