#include "config.h"
#include "sofia-sip/su.h"
#include "sofia-sip/su_wait.h"
#include "sofia-sip/su_alloc.h"
#include "sofia-sip/rbtree.h"
#include "su_module_debug.h"
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for su_timer.c:
Enumerations | |
enum | sut_running { reset, run_at_intervals, run_for_ever } |
Timer running status. More... | |
Functions | |
su_timer_t * | su_timer_create (su_task_r const task, su_duration_t msec) |
Create a timer. | |
void | su_timer_destroy (su_timer_t *t) |
Destroy a timer. | |
int | su_timer_set_interval (su_timer_t *t, su_timer_f wakeup, su_timer_arg_t *arg, su_duration_t interval) |
Set the timer for the given interval. | |
int | su_timer_set (su_timer_t *t, su_timer_f wakeup, su_timer_arg_t *arg) |
Set the timer for the default interval. | |
int | su_timer_set_at (su_timer_t *t, su_timer_f wakeup, su_wakeup_arg_t *arg, su_time_t when) |
Set timer at known time. | |
int | su_timer_run (su_timer_t *t, su_timer_f wakeup, su_timer_arg_t *arg) |
Set the timer for regular intervals. | |
int | su_timer_set_for_ever (su_timer_t *t, su_timer_f wakeup, su_timer_arg_t *arg) |
Set the timer for regular intervals. | |
int | su_timer_reset (su_timer_t *t) |
Reset the timer. | |
su_duration_t | su_timer_next_expires (su_timer_t const *t, su_time_t now) |
Calculate duration in milliseconds until next timer expires. | |
int | su_timer_reset_all (su_timer_t **timers, su_task_r task) |
Resets and frees all timers belonging to a task. | |
su_root_t * | su_timer_root (su_timer_t const *t) |
Get the root object owning the timer. |
enum sut_running |
su_timer_t* su_timer_create | ( | su_task_r const | task, | |
su_duration_t | msec | |||
) |
Create a timer.
Allocate and initialize an instance of su_timer_t.
task | a task for root object with which the timer will be associated | |
msec | the default duration of the timer |
void su_timer_destroy | ( | su_timer_t * | t | ) |
Destroy a timer.
Deinitialize and free an instance of su_timer_t.
t | pointer to the timer object |
int su_timer_reset | ( | su_timer_t * | t | ) |
Reset the timer.
Resets (stops) the given timer.
t | pointer to the timer object |
int su_timer_reset_all | ( | su_timer_t ** | timers, | |
su_task_r | task | |||
) |
Resets and frees all timers belonging to a task.
The function su_timer_destroy_all() resets and frees all timers belonging to the specified task in the queue.
timers | pointer to the timers | |
task | task owning the timers |
su_root_t* su_timer_root | ( | su_timer_t const * | t | ) |
Get the root object owning the timer.
Return pointer to the root object owning the timer.
t | pointer to the timer |
int su_timer_run | ( | su_timer_t * | t, | |
su_timer_f | wakeup, | |||
su_timer_arg_t * | arg | |||
) |
Set the timer for regular intervals.
Run the given timer continuously, call wakeup function repeately in the default interval. If a wakeup call is missed, try to make it up (in other words, this kind of timer fails miserably if time is adjusted and it should really use /proc/uptime instead of gettimeofday()).
While a continously running timer is active it must not be set using su_timer_set() or su_timer_set_at().
The timer must have an non-zero default interval.
t | pointer to the timer object | |
wakeup | pointer to the wakeup function | |
arg | argument given to the wakeup function |
int su_timer_set | ( | su_timer_t * | t, | |
su_timer_f | wakeup, | |||
su_timer_arg_t * | arg | |||
) |
Set the timer for the default interval.
Sets (starts) the given timer to expire after the default duration.
The timer must have an default duration.
t | pointer to the timer object | |
wakeup | pointer to the wakeup function | |
arg | argument given to the wakeup function |
int su_timer_set_at | ( | su_timer_t * | t, | |
su_timer_f | wakeup, | |||
su_wakeup_arg_t * | arg, | |||
su_time_t | when | |||
) |
Set timer at known time.
Sets the timer to expire at given time.
t | pointer to the timer object | |
wakeup | pointer to the wakeup function | |
arg | argument given to the wakeup function | |
when | time structure defining the wakeup time |
int su_timer_set_for_ever | ( | su_timer_t * | t, | |
su_timer_f | wakeup, | |||
su_timer_arg_t * | arg | |||
) |
Set the timer for regular intervals.
Run the given timer continuously, call wakeup function repeately in the default interval. While a continously running timer is active it must not be set using su_timer_set() or su_timer_set_at(). Unlike su_timer_run(), set for ever timer does not try to catchup missed callbacks.
The timer must have an non-zero default interval.
t | pointer to the timer object | |
wakeup | pointer to the wakeup function | |
arg | argument given to the wakeup function |
int su_timer_set_interval | ( | su_timer_t * | t, | |
su_timer_f | wakeup, | |||
su_timer_arg_t * | arg, | |||
su_duration_t | interval | |||
) |
Set the timer for the given interval.
Sets (starts) the given timer to expire after the specified duration.
t | pointer to the timer object | |
wakeup | pointer to the wakeup function | |
arg | argument given to the wakeup function | |
interval | duration in milliseconds before timer wakeup is called |