Multiplatform threading header. More...
#include <pthread.h>
#include <semaphore.h>
Go to the source code of this file.
Typedefs | |
typedef pthread_mutex_t | Mutex |
Mutex type. | |
typedef sem_t | Semaphore |
Semaphore type. | |
typedef pthread_t | Thread |
Thread type. | |
Functions | |
void | mutexCreate (Mutex *mutex) |
Mutex constructor. More... | |
void | mutexDelete (Mutex *mutex) |
Mutex destructor. More... | |
void | mutexLock (Mutex *mutex) |
Locks the mutex. More... | |
void | mutexUnlock (Mutex *mutex) |
Unlocks the mutex. More... | |
void | semaphoreCreate (Semaphore *semaphore, unsigned int value) |
Semaphore constructor. More... | |
void | semaphoreDelete (Semaphore *semaphore) |
Semaphore destructor. More... | |
void | semaphorePost (Semaphore *semaphore) |
Increases sempahore value. More... | |
int | semaphoreValue (Semaphore *semaphore) |
Sempahore value getter. More... | |
void | semaphoreWait (Semaphore *semaphore) |
Decreses sempahore value or waits. More... | |
void | threadCancel (Thread thread) |
Cancels the current thread. More... | |
void | threadCreate (Thread *thread, void *(*routine)(void *), void *args) |
Thread constructor. More... | |
void | threadCurrent (Thread *thread) |
Thread getter. More... | |
void | threadJoin (Thread thread) |
Waits for thread to finish. More... | |
void | threadSleep (unsigned int ms) |
Sleeps the current thread. More... | |
Multiplatform threading header.
void mutexCreate | ( | Mutex * | mutex | ) |
Mutex constructor.
mutex | output mutex object |
void mutexDelete | ( | Mutex * | mutex | ) |
Mutex destructor.
mutex | mutex object |
void mutexLock | ( | Mutex * | mutex | ) |
Locks the mutex.
mutex | mutex object |
void mutexUnlock | ( | Mutex * | mutex | ) |
Unlocks the mutex.
mutex | mutex object |
void semaphoreCreate | ( | Semaphore * | semaphore, |
unsigned int | value | ||
) |
Semaphore constructor.
semaphore | output semaphore object |
value | initial semaphore value |
void semaphoreDelete | ( | Semaphore * | semaphore | ) |
Semaphore destructor.
semaphore | semaphore object |
void semaphorePost | ( | Semaphore * | semaphore | ) |
Increases sempahore value.
semaphore | semaphore object |
int semaphoreValue | ( | Semaphore * | semaphore | ) |
Sempahore value getter.
semaphore | semaphore object |
void semaphoreWait | ( | Semaphore * | semaphore | ) |
Decreses sempahore value or waits.
Current thread waits until semaphore value isn't greater than zero and then decreases the value and continues the execturion.
void threadCancel | ( | Thread | thread | ) |
Cancels the current thread.
thread | thread object |
void threadCreate | ( | Thread * | thread, |
void *(*)(void *) | routine, | ||
void * | args | ||
) |
Thread constructor.
thread | thread output object |
*routine | routine that the thread executes |
args | arguments passed to the rutine function |
void threadCurrent | ( | Thread * | thread | ) |
Thread getter.
thread | thread output object |
void threadJoin | ( | Thread | thread | ) |
Waits for thread to finish.
thread | thread object |
void threadSleep | ( | unsigned int | ms | ) |
Sleeps the current thread.
ms | time to force current thread to sleep in milliseconds |