31 lines
769 B
C
31 lines
769 B
C
#include "../cdb_system.h"
|
|
#include <windows.h>
|
|
|
|
struct threadInfo{
|
|
sys_threadProc proc;
|
|
void * args;
|
|
};
|
|
|
|
DWORD WINAPI threadProc(void * tiarg){
|
|
struct threadInfo * ti = tiarg;
|
|
struct threadInfo currentTI = {.args = ti->args, .proc = ti->proc};
|
|
sys_heapFree(ti);
|
|
currentTI.proc(currentTI.args);
|
|
return 0;
|
|
}
|
|
|
|
sys_Bool sys_threadNew(sys_threadProc proc, void * arg){
|
|
struct threadInfo * ti = sys_heapAlloc(sizeof(struct threadInfo));
|
|
ti->proc = proc;
|
|
ti->args = arg;
|
|
if(CreateThread(NULL, 0, threadProc, ti, 0, NULL) == NULL){
|
|
sys_heapFree(ti);
|
|
return sys_False;
|
|
}else{
|
|
return sys_True;
|
|
}
|
|
}
|
|
|
|
void sys_threadSleep(unsigned long seconds){
|
|
Sleep(seconds * 1000);
|
|
} |