Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

SOFIAPUBFUN int su_timer_expire ( su_timer_queue_t *const   timers,
su_duration_t timeout,
su_time_t  now 
)

Check for expired timers in queue.

The function su_timer_expire() checks a timer queue and executes and removes expired timers from the queue. It also calculates the time when the next timer expires.

Parameters:
timerspointer to the timer queue
timeouttimeout in milliseconds [IN/OUT]
nowcurrent timestamp
Returns:
The number of expired timers.

Definition at line 528 of file su_timer.c.

References su_duration(), su_root_magic(), su_task_root(), su_time_add(), SU_TIME_CMP, su_time_diff(), su_timer_expire(), su_timer_s::sut_arg, su_timer_s::sut_duration, su_timer_s::sut_running, su_timer_s::sut_set, su_timer_s::sut_task, su_timer_s::sut_wakeup, su_timer_s::sut_when, and su_timer_s::sut_woken.

Referenced by su_base_port_run(), su_base_port_step(), su_root_osx_prepare_run(), and su_timer_expire().

{
  su_timer_t *t;
  su_timer_f f;
  int n = 0;

  if (timers_used(timers[0]) == 0)
    return 0;

  while ((t = timers_get(timers[0], 1))) {
    if (SU_TIME_CMP(t->sut_when, now) > 0) {
      su_duration_t at = su_duration(t->sut_when, now);

      if (at < *timeout || *timeout < 0)
      *timeout = at;

      break;
    }

    timers_remove(timers[0], 1);

    f = t->sut_wakeup; t->sut_wakeup = NULL;
    assert(f);

    if (t->sut_running == run_at_intervals) {
      while (t->sut_running == run_at_intervals &&
           t->sut_set == 0 &&
           t->sut_duration > 0) {
      if (su_time_diff(t->sut_when, now) > 0) {
        su_timer_set0(timers, t, f, t->sut_arg, t->sut_when, 0);
        break;
      }
      t->sut_when = su_time_add(t->sut_when, t->sut_duration);
      t->sut_woken++;
      f(su_root_magic(su_task_root(t->sut_task)), t, t->sut_arg), n++;
      }
    }
    else if (t->sut_running == run_for_ever) {
      t->sut_woken++;
      t->sut_when = now;
      f(su_root_magic(su_task_root(t->sut_task)), t, t->sut_arg), n++;
      if (t->sut_running == run_for_ever && t->sut_set == 0)
      su_timer_set0(timers, t, f, t->sut_arg, now, t->sut_duration);
    }
    else {
      t->sut_when = now;
      f(su_root_magic(su_task_root(t->sut_task)), t, t->sut_arg); n++;
    }
  }

  return n;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index