Classes | |
struct | ix_cond_s |
Typedefs | |
typedef ix_cond_s | ix_cond_t |
typedef int(*) | IX_COND_CHECK_FCT (void *) |
prototyp to check a condition | |
typedef int(*) | IX_COND_SET_FCT (void *) |
prototyp to set a condition | |
Functions | |
int | ix_cond_init (ix_cond_t *psync) |
int | ix_cond_is_wait (ix_cond_t *psync) |
int | ix_cond_wait (ix_cond_t *psync, int sec, IX_COND_CHECK_FCT cond_check, void *arg) |
void | ix_cond_set (ix_cond_t *psync, IX_COND_SET_FCT cond_set, void *arg) |
Example: Synchronization of threads
after initializing of ix_cond_t sync
calling ix_cond_wait() in thread1 waits till sync
is set in thread2 with ix_cond_set()
typedef struct ix_cond_s ix_cond_t |
ix condition as combination of pthread mutex and condition
int ix_cond_init | ( | ix_cond_t * | psync | ) |
iniitialize the ix conditon
psync | handle to condition |
int ix_cond_is_wait | ( | ix_cond_t * | psync | ) |
checks if psync is in waiting state
psync | handle to condition |
void ix_cond_set | ( | ix_cond_t * | psync, | |
IX_COND_SET_FCT | cond_set, | |||
void * | arg | |||
) |
set condition psync to come true, you can supply your own function to set your condition come true
psync | handle to condition | |
cond_set | function to check condition if cond_set != NULL, cond_set(arg) is called to set condition | |
arg | user data for cond_check() |
int ix_cond_wait | ( | ix_cond_t * | psync, | |
int | sec, | |||
IX_COND_CHECK_FCT | cond_check, | |||
void * | arg | |||
) |
wait for psync to come true, you can supply your own function to check if your condition is true
psync | handle to condition | |
sec | wait for maximal sec seconds | |
cond_check | if cond_check != NULL, cond_check(arg) is called to check wether condition we are waiting for is true. cond_check() has to return:
| |
arg | user data for cond_check() |