GPAC
Open Source Multimedia Framework. For more information, check out http://gpac.wp.mines-telecom.fr
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups
threading

Threading and Mutual Exclusion Functions. More...

+ Collaboration diagram for threading:

Typedefs

typedef u32(* gf_thread_run )(void *par)
 thread run function callback More...
 

Enumerations

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
}
 

Functions

GF_Thread * gf_th_new (const char *name)
 thread constructor More...
 
void gf_th_del (GF_Thread *th)
 thread destructor More...
 
GF_Err gf_th_run (GF_Thread *th, gf_thread_run run, void *par)
 thread execution More...
 
void gf_th_stop (GF_Thread *th)
 thread stoping More...
 
u32 gf_th_status (GF_Thread *th)
 thread status query More...
 
void gf_th_set_priority (GF_Thread *th, s32 priority)
 thread priority More...
 
u32 gf_th_id ()
 current thread ID More...
 
GF_Mutex * gf_mx_new (const char *name)
 
void gf_mx_del (GF_Mutex *mx)
 
u32 gf_mx_p (GF_Mutex *mx)
 
void gf_mx_v (GF_Mutex *mx)
 
Bool gf_mx_try_lock (GF_Mutex *mx)
 
s32 gf_mx_get_num_locks (GF_Mutex *mx)
 
GF_Semaphore * gf_sema_new (u32 MaxCount, u32 InitCount)
 
void gf_sema_del (GF_Semaphore *sm)
 
u32 gf_sema_notify (GF_Semaphore *sm, u32 nb_rel)
 
void gf_sema_wait (GF_Semaphore *sm)
 
Bool gf_sema_wait_for (GF_Semaphore *sm, u32 time_out)
 

Detailed Description

This section documents the threading of the GPAC framework. These provide an easy way to implement safe multithreaded tools.

Typedef Documentation

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
paropaque user data
Returns
exit code of the thread, usually 1 for error and 0 if normal execution

Enumeration Type Documentation

anonymous enum

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

anonymous enum

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

Function Documentation

GF_Thread* gf_th_new ( const char *  name)

Constructs a new thread object

Parameters
namelog name of the thread if any

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_th_del ( GF_Thread *  th)

Kills the thread if running and destroys the object

Parameters
ththe thread object

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_Err gf_th_run ( GF_Thread *  th,
gf_thread_run  run,
void *  par 
)

Executes the thread with the given function

Parameters
ththe thread object
runthe function this thread will call
parthe 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.

+ Here is the caller graph for this function:

void gf_th_stop ( GF_Thread *  th)

Waits for the thread exit until return

Parameters
ththe thread object

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 gf_th_status ( GF_Thread *  th)

Gets the thread status

Parameters
ththe thread object

+ Here is the caller graph for this function:

void gf_th_set_priority ( GF_Thread *  th,
s32  priority 
)

Sets the thread execution priority level.

Parameters
ththe thread object
prioritythe desired priority
Note
this should be used with caution, especially use of real-time priorities.

+ Here is the caller graph for this function:

u32 gf_th_id ( )

Gets the ID of the current thread the caller is in.

+ Here is the caller graph for this function:

GF_Mutex* gf_mx_new ( const char *  name)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_mx_del ( GF_Mutex *  mx)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 gf_mx_p ( GF_Mutex *  mx)

+ Here is the call graph for this function:

void gf_mx_v ( GF_Mutex *  mx)

+ Here is the call graph for this function:

Bool gf_mx_try_lock ( GF_Mutex *  mx)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

s32 gf_mx_get_num_locks ( GF_Mutex *  mx)

+ Here is the call graph for this function:

GF_Semaphore* gf_sema_new ( u32  MaxCount,
u32  InitCount 
)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_sema_del ( GF_Semaphore *  sm)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 gf_sema_notify ( GF_Semaphore *  sm,
u32  nb_rel 
)

+ Here is the caller graph for this function:

void gf_sema_wait ( GF_Semaphore *  sm)

+ Here is the caller graph for this function:

Bool gf_sema_wait_for ( GF_Semaphore *  sm,
u32  time_out 
)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: