Client Library - Timer API


Detailed Description

s_timer_* api calls is designed for setting timers, and timer callbacks for any window.

programmers should use these timers rather than using signals or looping threads to be thread safe. and do not forget that these timers are not real-time.

Example:
for further information look in demo/timer/

 // this is the timer callback
 void timer_cb (s_window_t *window, s_timer_t *timer)
 {
        // do what ever you want

        // use s_timer_* functions to change anything on timer,
        s_timer_timeval(window, timeval, new_timeval);
        s_timer_del(window, timer);
        s_timer_uninit(timer);

        // or to work directly on time struct
        s_thread_mutex_lock(window->timers->mut);
        // do anything on window->timers->*, or timer->*
        s_thread_mutex_unlock(window->timers->mut);
 }

 s_timer_t *tmr;
 s_window_t *window;

 // initialize a timer, and set a callback function
 s_timer_init(&tmr);
 timer->timeval = 2000;
 timer->cb = timer_cb;
 s_timer_add(window, timer);

 // timeval timer can be changed any time
 s_timer_timeval(window, timer, 3000);

 // delete the timer from window, and uninitialize
 s_timer_del(window, timer);
 s_timer_uninit(tmr);


Data Structures

struct  s_timer_s
 timer struct More...
struct  s_timers_s
 timers struct More...

Functions

int s_timer_init (s_timer_t **timer)
 initialize the timer struct.
int s_timer_timeval (s_window_t *window, s_timer_t *timer, int timeval)
 updates/sets the timeval for the given timer
int s_timer_uninit (s_timer_t *timer)
 uninitialize the timer struct
int s_timer_del (s_window_t *window, s_timer_t *timer)
 deletes a timer from windows` timers list
int s_timer_add (s_window_t *window, s_timer_t *timer)
 adds a timer to windows` timers list
int s_timers_init (s_window_t *window)
 initialize the timers struct for given window
int s_timers_uninit (s_window_t *window)
 uninitialize the timers struct for given window


Function Documentation

int s_timer_add ( s_window_t window,
s_timer_t timer 
)

adds a timer to windows` timers list

Parameters:
*window - window to attach the timer
*timer - the timer
Returns:
0 on success, 1 on error.

int s_timer_del ( s_window_t window,
s_timer_t timer 
)

deletes a timer from windows` timers list

Parameters:
*window - window that holds the timer
*timer - timer
Returns:
0 on success, 1 on error.

int s_timer_init ( s_timer_t **  timer  ) 

initialize the timer struct.

Parameters:
**timer - address of the timer pointer.
Returns:
0 on success, 1 on error.

int s_timer_timeval ( s_window_t window,
s_timer_t timer,
int  timeval 
)

updates/sets the timeval for the given timer

Parameters:
*window - window that holds the timer
*timer - the timer
timeval - timeval to set the timer
Returns:
0 on success, 1 on error.

int s_timer_uninit ( s_timer_t timer  ) 

uninitialize the timer struct

Parameters:
*timer - the timer
Returns:
0 on success, 1 on error.

int s_timers_init ( s_window_t window  ) 

initialize the timers struct for given window

Parameters:
*window - window
Returns:
0 on success, 1 on error.

int s_timers_uninit ( s_window_t window  ) 

uninitialize the timers struct for given window

Parameters:
*window - window
Returns:
0 on success, 1 on error.


Generated on Wed Dec 27 17:53:06 2006 for xynth-0.8.40 by  doxygen 1.4.7