This commit is contained in:
JiXieShi
2024-09-21 23:07:22 +08:00
parent 6c9a999c71
commit 8f7f72712c
27 changed files with 100 additions and 81 deletions

View File

@@ -4,10 +4,13 @@
extern "C" {
#endif
typedef void (*Thread_Func_t)(void *pArg);
#include "SDL3/SDL.h"
void ThreadCreat(Thread_Func_t func, unsigned int stackSize, void *pArg);
void ThreadStop();
typedef int (*Thread_Func_t)(void *pArg);
SDL_Thread *ThreadCreat(Thread_Func_t func, char *name, void *pArg);
void ThreadStop(SDL_Thread *t);
#ifdef __cplusplus
}
#endif

View File

@@ -1,11 +1,17 @@
#include "sim_thread.h"
#include <windows.h>
#include <process.h>
void ThreadCreat(Thread_Func_t func, unsigned int stackSize, void *pArg) {
_beginthread(func, stackSize, pArg);
SDL_Thread *ThreadCreat(Thread_Func_t func, char *name, void *pArg) {
SDL_Thread *t = SDL_CreateThread(func, name, NULL);
if (!t) {
SDL_Log("CreateThread: %s", SDL_GetError);
return nullptr;
}
return t;
}
void ThreadStop() {
_endthread();
void ThreadStop(SDL_Thread *t) {
SDL_WaitThread(t, NULL);
}