|  | Home | Documentation | Portable threads and locking support updated Thu Mar 21 2024 by Robert van Engelen |

- Main Page
- Related Pages
- Classes
- Files

Portable threads and locking support

The threads.h and threads.c code define the following portable API:

- THREAD_TYPE portable thread type
- THREAD_ID returns current thread ID of type THREAD_TYPE*
- THREAD_CREATE(t,f,a) start thread (THREAD_TYPE*)t for f(a), return 0 if OK
- THREAD_CREATEX(t,f,a) Windows only: start joinable thread (THREAD_TYPE*)t for f(a), return 0 if OK
- THREAD_CLOSE(t) Windows only: close and destroy thread ID (a handle) when done
- THREAD_DETACH(t) detach thread (THREAD_TYPE*)t
- THREAD_JOIN(t) wait to join (THREAD_TYPE*)t
- THREAD_EXIT exit the current thread
- THREAD_CANCEL(t) kill a thread, dangerous, use only in extreme cases!
- MUTEX_TYPE portable mutex type
- MUTEX_INITIALIZER global initializer value for static locks
- MUTEX_SETUP(m) setup lock (MUTEX_TYPE*)m
- MUTEX_CLEANUP(m) cleanup lock (MUTEX_TYPE*)m
- MUTEX_LOCK(m) acquire lock (MUTEX_TYPE*)m
- MUTEX_UNLOCK(m) release lock (MUTEX_TYPE*)m
- COND_TYPE portable condition variable type
- COND_SETUP(c) setup condition variable (COND_TYPE*)c
- COND_CLEANUP(c) cleanup condition variable (COND_TYPE*)c
- COND_SIGNAL(c) signal condition variable (COND_TYPE*)c
- COND_WAIT(c,m) wait on variable (COND_TYPE*)c in mutex (MUTEX_TYPE*)m