11 void Thread_Shutdown(void)
15 qboolean Thread_HasThreads(void)
20 void *_Thread_CreateMutex(const char *filename, int fileline)
22 pthread_mutex_t *mutexp = (pthread_mutex_t *) Z_Malloc(sizeof(pthread_mutex_t));
24 Sys_PrintfToTerminal("%p create %s:%i\n" , mutexp, filename, fileline);
26 pthread_mutex_init(mutexp, NULL);
30 void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
32 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
34 Sys_PrintfToTerminal("%p destroy %s:%i\n", mutex, filename, fileline);
36 pthread_mutex_destroy(mutexp);
40 int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
42 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
44 Sys_PrintfToTerminal("%p lock %s:%i\n" , mutex, filename, fileline);
46 return pthread_mutex_lock(mutexp);
49 int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
51 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
53 Sys_PrintfToTerminal("%p unlock %s:%i\n" , mutex, filename, fileline);
55 return pthread_mutex_unlock(mutexp);
58 void *Thread_CreateCond(void)
60 pthread_cond_t *condp = (pthread_cond_t *) Z_Malloc(sizeof(pthread_cond_t));
61 pthread_cond_init(condp, NULL);
65 void Thread_DestroyCond(void *cond)
67 pthread_cond_t *condp = (pthread_cond_t *) cond;
68 pthread_cond_destroy(condp);
72 int Thread_CondSignal(void *cond)
74 pthread_cond_t *condp = (pthread_cond_t *) cond;
75 return pthread_cond_signal(condp);
78 int Thread_CondBroadcast(void *cond)
80 pthread_cond_t *condp = (pthread_cond_t *) cond;
81 return pthread_cond_broadcast(condp);
84 int Thread_CondWait(void *cond, void *mutex)
86 pthread_cond_t *condp = (pthread_cond_t *) cond;
87 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
88 return pthread_cond_wait(condp, mutexp);
91 void *Thread_CreateThread(int (*fn)(void *), void *data)
93 pthread_t *threadp = (pthread_t *) Z_Malloc(sizeof(pthread_t));
94 int r = pthread_create(threadp, NULL, (void * (*) (void *)) fn, data);
103 int Thread_WaitThread(void *thread, int retval)
105 pthread_t *threadp = (pthread_t *) thread;
106 void *status = (void *) (intptr_t) retval;
107 pthread_join(*threadp, &status);
109 return (int) (intptr_t) status;