Scheduler Functions

Scheduler Functions — Support for delayed or periodic execution of functions

Synopsis


#include <monitor/monitor.h>


void        mon_sched_doit                  (void);
void        (*mon_sched_cb)                 (void *ptr);
int         mon_sched_at                    (mon_sched_cb cb,
                                             void *data,
                                             struct timeval *when);
int         mon_sched_once                  (mon_sched_cb cb,
                                             void *data,
                                             int delay);
int         mon_sched_periodic              (mon_sched_cb cb,
                                             void *data,
                                             int freq);
int         mon_sched_remove                (mon_sched_cb cb,
                                             void *data);
int         mon_sched_freq_mod              (mon_sched_cb cb,
                                             void *data,
                                             int freq);
void        mon_sched_done                  (void);

Description

Details

mon_sched_doit ()

void        mon_sched_doit                  (void);

Calls all callbacks that have met their deadline.


mon_sched_cb ()

void        (*mon_sched_cb)                 (void *ptr);

Prototype of schedulable functions.

ptr :Opaque pointer that will be passed to the function.

mon_sched_at ()

int         mon_sched_at                    (mon_sched_cb cb,
                                             void *data,
                                             struct timeval *when);

Schedules a function to run once at the specified time.

cb :the function to schedule.
data :opaque data that will be passed to the function.
when :a struct timeval holding the deadline.
Returns :0 if successful or an error code.

mon_sched_once ()

int         mon_sched_once                  (mon_sched_cb cb,
                                             void *data,
                                             int delay);

Schedules a function to run once after a specified delay.

cb :the function to schedule.
data :opaque data that will be passed to the function.
delay :delay in milliseconds.
Returns :0 if successful or an error code.

mon_sched_periodic ()

int         mon_sched_periodic              (mon_sched_cb cb,
                                             void *data,
                                             int freq);

Schedules a function to run periodically with the specified frequency.

cb :the function to schedule.
data :opaque data that will be passed to the function.
freq :frequency in milliseconds.
Returns :0 if successful or an error code.

mon_sched_remove ()

int         mon_sched_remove                (mon_sched_cb cb,
                                             void *data);

Removes a previously scheduled function. Both the cb and data arguments must match what was given when the function was scheduled.

cb :the function that was scheduled.
data :opaque data to be passed to the function.
Returns :0 if successful or an error code.

mon_sched_freq_mod ()

int         mon_sched_freq_mod              (mon_sched_cb cb,
                                             void *data,
                                             int freq);

Modifies the frequency of a fuction that was scheduled to run periodically.

cb :the function that was scheduled.
data :opaque data to be passed to the function.
freq :the new frequency in milliseconds.
Returns :0 if successful or an error code.

mon_sched_done ()

void        mon_sched_done                  (void);

Removes all scheduled functions and deallocates any internal resources held by the scheduler.