update
This commit is contained in:
parent
63fb35c899
commit
667434cadc
3 changed files with 59 additions and 0 deletions
|
|
@ -31,4 +31,36 @@ void MDEThreadJoin(MDEThread thread) {
|
|||
WaitForSingleObject(thread, INFINITE);
|
||||
}
|
||||
#else
|
||||
#include <pthread.h>
|
||||
|
||||
static void* call_wrapper(void* param) {
|
||||
void** p = param;
|
||||
void (*call)(void* user_data) = p[0];
|
||||
void* ud = p[1];
|
||||
free(p);
|
||||
|
||||
call(ud);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MDEThread MDEThreadCreate(void (*call)(void* user_data), void* user_data) {
|
||||
void** p = malloc(sizeof(*p) * 2);
|
||||
pthread_t* t = malloc(sizeof(*t));
|
||||
|
||||
p[0] = call;
|
||||
p[1] = user_data;
|
||||
|
||||
pthread_create(t, NULL, call_wrapper, p);
|
||||
return t;
|
||||
}
|
||||
|
||||
void MDEThreadDestroy(MDEThread thread) {
|
||||
free(thread);
|
||||
}
|
||||
|
||||
void MDEThreadJoin(MDEThread thread) {
|
||||
void* p;
|
||||
pthread_join(thread, &p);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue