Main Page | Modules | Data Structures | Data Fields

Timer


Detailed Description

Lightweight timer/repeater support within a task. Units are floats in seconds with an internal precision up to usec, but subjects to client's event handlers so don't expect a lot.
For best results, please use in conjunction with the Time module (peak_time*).


Typedefs

typedef __peak_timer * peak_timer
 Opaque timer pointer type.

typedef void(* peak_timer_callback )(peak_timer t, void *context)
 Timer callback.


Functions

peak_timer peak_timer_create (double fire, double interval, peak_timer_callback callout, void *context)
 Create a timer.

void peak_timer_configure (peak_timer t, double fire, double interval)
 (Re)configure a timer.

double peak_timer_get_firetime (peak_timer t)
 Get timer's fire date time.

double peak_timer_get_interval (peak_timer t)
 Get timer's repeat-interval time.

void * peak_timer_get_context (peak_timer t)
 Get timer's extra application-defined context.

void peak_timer_set_context (peak_timer t, void *context)
 Change the context pointer of a timer.


Function Documentation

void peak_timer_configure peak_timer  t,
double  fire,
double  interval
 

(Re)configure a timer.

Parameters:
t The timer reference to configure.
fire Relative fire time in second. 0 means immediate fire (as soon as possible, usually during the next event loop). A value of -1.0 means never fire, and can be useful to temporarily "disable" a timer.
interval Repeat interval in second. Use -1.0 for a one-shot timer. Value must be strictly positive for repeating timer.

peak_timer peak_timer_create double  fire,
double  interval,
peak_timer_callback  callout,
void *  context
 

Create a timer.

Note that the timer isn't activated until you add it to the task of your choice (usually peak_task_self()) with peak_task_timer_add().

Parameters:
fire Relative fire time in second. 0 means immediate fire (as soon as possible, usually during the next event loop). A value of -1.0 means never fire, and can be useful to temporarily "disable" a timer.
interval Repeat interval in second. Use -1.0 for a one-shot timer. Value must be strictly positive for repeating timer.
callout A pointer to your timer callback function which is triggered when the timer fires.
context An extra application-defined pointer that will be passed to your timer callback function (it's not used by the library).
Returns:
A newly allocated peak_timer reference or NULL if the timer cannot be created.

void* peak_timer_get_context peak_timer  t  ) 
 

Get timer's extra application-defined context.

Parameters:
t The timer reference.
Returns:
Context pointer.

double peak_timer_get_firetime peak_timer  t  ) 
 

Get timer's fire date time.

Parameters:
t The timer reference.
Returns:
Absolute time in second before the timer fires (if it is added to a task).

double peak_timer_get_interval peak_timer  t  ) 
 

Get timer's repeat-interval time.

Parameters:
t The timer reference.
Returns:
Interval time in second.

void peak_timer_set_context peak_timer  t,
void *  context
 

Change the context pointer of a timer.

Parameters:
t The timer reference.
context An extra application-defined pointer that will be passed to your timer callback function (it's not used by the library).


Generated on Thu Jan 8 18:16:24 2004 for the PEAK Library by doxygen     SourceForge.net Logo