From d124aee4d78db389117a8eda60c12a829489622b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Apr 2014 06:11:40 -0700 Subject: Remove the old thread wrappers for the new ones --- Alc/threads.c | 118 +--------------------------------------------------------- 1 file changed, 2 insertions(+), 116 deletions(-) (limited to 'Alc/threads.c') diff --git a/Alc/threads.c b/Alc/threads.c index d910716c..10109630 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -46,59 +46,6 @@ extern inline int almtx_trylock(almtx_t *mtx); #include #include -typedef struct althread_info { - ALuint (*func)(ALvoid*); - ALvoid *ptr; - HANDLE hdl; -} althread_info; - -static DWORD CALLBACK StarterFunc(void *ptr) -{ - althread_info *inf = (althread_info*)ptr; - ALuint ret; - - ret = inf->func(inf->ptr); - ExitThread((DWORD)ret); - - return (DWORD)ret; -} - - -ALboolean StartThread(althread_t *thread, ALuint (*func)(ALvoid*), ALvoid *ptr) -{ - althread_info *info; - DWORD dummy; - - info = malloc(sizeof(*info)); - if(!info) return AL_FALSE; - - info->func = func; - info->ptr = ptr; - - info->hdl = CreateThread(NULL, THREAD_STACK_SIZE, StarterFunc, info, 0, &dummy); - if(!info->hdl) - { - free(info); - return AL_FALSE; - } - - *thread = info; - return AL_TRUE; -} - -ALuint StopThread(althread_t thread) -{ - DWORD ret = 0; - - WaitForSingleObject(thread->hdl, INFINITE); - GetExitCodeThread(thread->hdl, &ret); - CloseHandle(thread->hdl); - - free(thread); - - return (ALuint)ret; -} - void SetThreadName(const char *name) { @@ -243,66 +190,9 @@ int almtx_timedlock(almtx_t *mtx, const struct timespec *ts) #include #endif -typedef struct althread_info { - ALuint (*func)(ALvoid*); - ALvoid *ptr; - ALuint ret; - pthread_t hdl; -} althread_info; - -static void *StarterFunc(void *ptr) -{ - althread_info *inf = (althread_info*)ptr; - inf->ret = inf->func(inf->ptr); - return NULL; -} - -ALboolean StartThread(althread_t *thread, ALuint (*func)(ALvoid*), ALvoid *ptr) -{ - pthread_attr_t attr; - althread_info *info; - - info = malloc(sizeof(*info)); - if(!info) return AL_FALSE; - - if(pthread_attr_init(&attr) != 0) - { - free(info); - return AL_FALSE; - } - if(pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE) != 0) - { - pthread_attr_destroy(&attr); - free(info); - return AL_FALSE; - } - - info->func = func; - info->ptr = ptr; - if(pthread_create(&info->hdl, &attr, StarterFunc, info) != 0) - { - pthread_attr_destroy(&attr); - free(info); - return AL_FALSE; - } - pthread_attr_destroy(&attr); - - *thread = info; - return AL_TRUE; -} - -ALuint StopThread(althread_t thread) -{ - ALuint ret; - - pthread_join(thread->hdl, NULL); - ret = thread->ret; - - free(thread); - - return ret; -} +extern inline althrd_t althrd_current(void); +extern inline int althrd_sleep(const struct timespec *ts, struct timespec *rem); void SetThreadName(const char *name) @@ -322,10 +212,6 @@ void SetThreadName(const char *name) } -extern inline althrd_t althrd_current(void); -extern inline int althrd_sleep(const struct timespec *ts, struct timespec *rem); - - typedef struct thread_cntr { althrd_start_t func; void *arg; -- cgit v1.2.3