windows support
This commit is contained in:
parent
f1cd631aae
commit
b9004acd79
16 changed files with 208 additions and 32 deletions
34
core/thread.c
Normal file
34
core/thread.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include <MDE/Core/Thread.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
static DWORD WINAPI call_wrapper(LPVOID param) {
|
||||
void** p = param;
|
||||
void (*call)(void* user_data) = p[0];
|
||||
void* ud = p[1];
|
||||
free(p);
|
||||
|
||||
call(ud);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
MDEThread MDEThreadCreate(void (*call)(void* user_data), void* user_data) {
|
||||
void** p = malloc(sizeof(*p) * 2);
|
||||
|
||||
p[0] = call;
|
||||
p[1] = user_data;
|
||||
|
||||
return CreateThread(NULL, 0, call_wrapper, (void*)p, 0, NULL);
|
||||
}
|
||||
|
||||
void MDEThreadDestroy(MDEThread thread) {
|
||||
CloseHandle(thread);
|
||||
}
|
||||
|
||||
void MDEThreadJoin(MDEThread thread) {
|
||||
WaitForSingleObject(thread, INFINITE);
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue