SW#
All Files Functions Variables Typedefs Macros
Typedefs | Functions
thread.h File Reference

Multiplatform threading header. More...

#include <pthread.h>
#include <semaphore.h>
Include dependency graph for thread.h:
This graph shows which files directly or indirectly include this file:

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...
 

Detailed Description

Multiplatform threading header.

Function Documentation

void mutexCreate ( Mutex mutex)

Mutex constructor.

Parameters
mutexoutput mutex object
void mutexDelete ( Mutex mutex)

Mutex destructor.

Parameters
mutexmutex object
void mutexLock ( Mutex mutex)

Locks the mutex.

Parameters
mutexmutex object
void mutexUnlock ( Mutex mutex)

Unlocks the mutex.

Parameters
mutexmutex object
void semaphoreCreate ( Semaphore semaphore,
unsigned int  value 
)

Semaphore constructor.

Parameters
semaphoreoutput semaphore object
valueinitial semaphore value
void semaphoreDelete ( Semaphore semaphore)

Semaphore destructor.

Parameters
semaphoresemaphore object
void semaphorePost ( Semaphore semaphore)

Increases sempahore value.

Parameters
semaphoresemaphore object
int semaphoreValue ( Semaphore semaphore)

Sempahore value getter.

Parameters
semaphoresemaphore object
Returns
semaphore value
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.

Parameters
threadthread object
void threadCreate ( Thread thread,
void *(*)(void *)  routine,
void *  args 
)

Thread constructor.

Parameters
threadthread output object
*routineroutine that the thread executes
argsarguments passed to the rutine function
void threadCurrent ( Thread thread)

Thread getter.

Parameters
threadthread output object
void threadJoin ( Thread  thread)

Waits for thread to finish.

Parameters
threadthread object
void threadSleep ( unsigned int  ms)

Sleeps the current thread.

Parameters
mstime to force current thread to sleep in milliseconds