Threading and Mutual Exclusion Functions.
More...
|
enum | { GF_THREAD_STATUS_STOP = 0,
GF_THREAD_STATUS_RUN = 1,
GF_THREAD_STATUS_DEAD = 2
} |
| Thread states. More...
|
|
enum | {
GF_THREAD_PRIORITY_IDLE =0,
GF_THREAD_PRIORITY_LESS_IDLE,
GF_THREAD_PRIORITY_LOWEST,
GF_THREAD_PRIORITY_LOW,
GF_THREAD_PRIORITY_NORMAL,
GF_THREAD_PRIORITY_HIGH,
GF_THREAD_PRIORITY_HIGHEST,
GF_THREAD_PRIORITY_REALTIME,
GF_THREAD_PRIORITY_REALTIME_END =255
} |
|
*This section documents the threading of the GPAC framework. These provide an easy way to implement *safe multithreaded tools.
*The abstracted thread object allows you to execute some code independently of the main process of your application.
typedef u32(* gf_thread_run)(void *par) |
*The gf_thread_run type is the type for the callback of the gf_thread_run function
- Parameters
-
- Returns
- exit code of the thread, usually 1 for error and 0 if normal execution
*The abstracted mutex object allows you to make sure that portions of the code (typically access to variables) cannot be executed *by two threads (or a thread and the main process) at the same time.
*The abstracted semaphore object allows you to control how portions of the code (typically access to variables) are executed *by two threads (or a thread and the main process) at the same time. The best image for a semaphore is a limited set *of money coins (always easy to understand hmm?). If no money is in the set, nobody can buy anything until a coin is *put back in the set. When the set is full, the money is wasted (call it "the bank"...).
*Inidcates the execution status of a thread
Enumerator |
---|
GF_THREAD_STATUS_STOP |
the thread has been initialized but is not started yet
|
GF_THREAD_STATUS_RUN |
the thread is running
|
GF_THREAD_STATUS_DEAD |
the thread has exited its body function
|
thread priorities
Enumerator |
---|
GF_THREAD_PRIORITY_IDLE |
Idle Priority
|
GF_THREAD_PRIORITY_LESS_IDLE |
Less Idle Priority
|
GF_THREAD_PRIORITY_LOWEST |
Lowest Priority
|
GF_THREAD_PRIORITY_LOW |
Low Priority
|
GF_THREAD_PRIORITY_NORMAL |
Normal Priority (the default one)
|
GF_THREAD_PRIORITY_HIGH |
High Priority
|
GF_THREAD_PRIORITY_HIGHEST |
Highest Priority
|
GF_THREAD_PRIORITY_REALTIME |
First real-time priority
|
GF_THREAD_PRIORITY_REALTIME_END |
Last real-time priority
|
*Constructs a new thread object
- Parameters
-
log | name of the thread if any |
Kills the thread if running and destroys the object
- Parameters
-
*Executes the thread with the given function
- Parameters
-
th | the thread object |
run | the function this thread will call |
par | the argument to the function the thread will call |
- Note
- A thread may be run several times but cannot be run twice in the same time.
*Waits for the thread exit until return
- Parameters
-
*Gets the thread status
- Parameters
-
void gf_th_set_priority |
( |
GF_Thread * |
th, |
|
|
s32 |
priority |
|
) |
| |
*Sets the thread execution priority level.
- Parameters
-
th | the thread object |
priority | the desired priority |
- Note
- this should be used with caution, especially use of real-time priorities.
*Gets the ID of the current thread the caller is in.