su_timer.c File Reference


Detailed Description

Timer interface for su_root.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden> Created: Fri Apr 28 15:45:41 2000 ppessi

#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 { ,
  run_at_intervals,
  run_for_ever
}

Functions

su_timer_tsu_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.
int su_timer_reset_all (su_timer_t **timers, su_task_r task)
 Resets and frees all timers belonging to a task.
su_root_tsu_timer_root (su_timer_t const *t)
 Get the root object owning the timer.

Enumeration Type Documentation

enum sut_running

Enumerator:
run_at_intervals  Compensate missed wakeup calls.
run_for_ever  Do not compensate.


Function Documentation

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.

Parameters:
task a task for root object with which the timer will be associated
msec the default duration of the timer
Returns:
A pointer to allocated timer instance, NULL on error.

void su_timer_destroy ( su_timer_t t  ) 

Destroy a timer.

Deinitialize and free an instance of su_timer_t.

Parameters:
t pointer to the timer object

int su_timer_reset ( su_timer_t t  ) 

Reset the timer.

Resets (stops) the given timer.

Parameters:
t pointer to the timer object
Returns:
0 if successful, -1 otherwise.

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.

Parameters:
timers pointer to the timers
task task owning the timers
Returns:
Number of timers reset.

su_root_t* su_timer_root ( su_timer_t const *  t  ) 

Get the root object owning the timer.

The function su_timer_root() return pointer to the root object owning the timer.

Parameters:
t pointer to the timer
Returns:
Pointer to the root object owning 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.

Parameters:
t pointer to the timer object
wakeup pointer to the wakeup function
arg argument given to the wakeup function
Returns:
0 if successful, -1 otherwise.

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.

Parameters:
t pointer to the timer object
wakeup pointer to the wakeup function
arg argument given to the wakeup function
Returns:
0 if successful, -1 otherwise.

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.

Parameters:
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
Returns:
0 if successful, -1 otherwise.

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.

Parameters:
t pointer to the timer object
wakeup pointer to the wakeup function
arg argument given to the wakeup function
Returns:
0 if successful, -1 otherwise.

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.

Parameters:
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
Returns:
0 if successful, -1 otherwise.


Sofia-SIP 1.12.1 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.