P E R I O D I C _ T A S K S

EXTERNAL / PUBLIC. More...

Functions

dessert_periodic_tdessert_periodic_add (dessert_periodiccallback_t *c, void *data, const struct timeval *scheduled, const struct timeval *interval)
 Adds a delayed/periodic task to the task list.
dessert_periodic_tdessert_periodic_add_delayed (dessert_periodiccallback_t *c, void *data, int delay)
 Adds a delayed task to the task list.
int dessert_periodic_del (dessert_periodic_t *p)
 Removes a delayed/periodic task from the task list.

Detailed Description

EXTERNAL / PUBLIC.


Function Documentation

dessert_periodic_t* dessert_periodic_add ( dessert_periodiccallback_t c,
void *  data,
const struct timeval *  scheduled,
const struct timeval *  interval 
)

Adds a delayed/periodic task to the task list.

Parameters:
[in] c callback to call when task is scheduled
[in] data data to give to the callback
[in] scheduled when should the callback be called the first time
[in] interval how often should it be called (set to NULL if only once)
Return values:
pointer if the callback was added successfully
NULL otherwise
Note:
The GNU C Library Documentation states about the tv_usec member of the struct timeval: This is the rest of the elapsed time (a fraction of a second), represented as the number of microseconds. It is always less than one million. So, to make sure this invariant is always met, consider using the provided TIMEVAL_ADD() macro.
Description:
Examples:
  • Register a callback function to be executed every 1.5 seconds - and delay the first call to it for another 1.5 seconds:
      struct timeval interval;
      interval.tv_sec = 1;
      interval.tv_usec = 500000;
    
      struct timeval schedule;
      gettimeofday(&schedule, NULL);
      TIMEVAL_ADD(&schedule, 1, 500000);
    
      dessert_periodic_add(callback, NULL, &schedule, &interval);
    

Here is the caller graph for this function:

dessert_periodic_t* dessert_periodic_add_delayed ( dessert_periodiccallback_t c,
void *  data,
int  delay 
)

Adds a delayed task to the task list.

This is an easier version of dessert_periodic_add() taking a single delay as parameter.

Parameters:
[in] c callback to call when task is scheduled
[in] data data to give to the callback
[in] delay the delay in seconds

DESCRIPTION:

int dessert_periodic_del ( dessert_periodic_t p  ) 

Removes a delayed/periodic task from the task list.

Parameters:
[in] p pointer to task description
Returns:
-1 on failure, 0 if the task was removed

DESCRIPTION:


Generated by  doxygen 1.6.2