Conditions


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)

Detailed Description

This modules defines some utilities to ease pthread conditions. Setting and checking for a condition can be done by user supplied functions with some arbitrary user data as argument.

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 Documentation

typedef struct ix_cond_s ix_cond_t

ix condition as combination of pthread mutex and condition


Function Documentation

int ix_cond_init ( ix_cond_t psync  ) 

iniitialize the ix conditon

Parameters:
psync handle to condition
Returns:
  • <0: Error
  • 0: OK

int ix_cond_is_wait ( ix_cond_t psync  ) 

checks if psync is in waiting state

Parameters:
psync handle to condition
Returns:
  • 1: yes
  • 0: no

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

Parameters:
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

Parameters:
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:
  • <0: error
  • 0 : condition false
  • 1 : condition true
arg user data for cond_check()
Returns:
  • <0: error
  • 0: timeout
  • 1: condition true


Generated on 4 Mar 2014 for ixtools by  doxygen 1.4.7