libgpac
Documentation of the core library of GPAC
|
Semaphore. More...
Functions | |
GF_Semaphore * | gf_sema_new (u32 MaxCount, u32 InitCount) |
semaphore constructor More... | |
void | gf_sema_del (GF_Semaphore *sm) |
semaphore destructor More... | |
Bool | gf_sema_notify (GF_Semaphore *sm, u32 nb_rel) |
semaphore notification. More... | |
Bool | gf_sema_wait (GF_Semaphore *sm) |
semaphore wait More... | |
Bool | gf_sema_wait_for (GF_Semaphore *sm, u32 time_out) |
semaphore time wait More... | |
The semaphore object allows controlling 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"...).
Constructs a new semaphore object
MaxCount | the maximum notification count of this semaphore |
InitCount | the initial notification count of this semaphore upon construction |
void gf_sema_del | ( | GF_Semaphore * | sm | ) |
Destructs the semaphore object. This will wait for the semaphore to be released if needed.
sm | the semaphore object |
Notifies the semaphore of a certain amount of releases.
sm | the semaphore object |
nb_rel | sm the number of release to notify |
Bool gf_sema_wait | ( | GF_Semaphore * | sm | ) |
Waits for the semaphore to be accessible (eg, may wait an infinite time).
sm | the semaphore object |
Waits for a certain for the semaphore to be accessible, and returns when semaphore is accessible or wait time has passed.
sm | the semaphore object |
time_out | the amount of time to wait for the release in milliseconds |