205 warning(0,
"Timers shutting down with %ld active timers.",
230 t = gw_malloc(
sizeof(*t));
270 if (interval < timer->elapses && timer->
index == 0)
285 wakeup = timer->
index == 0;
290 timer->
event = event;
347 debug(
"timers", 0,
"Aborting %s timer.",
361 heap = gw_malloc(
sizeof(*heap));
362 heap->
tab = gw_malloc(
sizeof(heap->
tab[0]));
391 last = heap->
len - 1;
407 heap->
tab = gw_realloc(heap->
tab,
408 heap->
len *
sizeof(heap->
tab[0]));
411 heap->
tab[heap->
len - 1] = timer;
429 if (index1 == index2)
432 t = heap->
tab[index1];
433 heap->
tab[index1] = heap->
tab[index2];
434 heap->
tab[index2] = t;
468 t = heap->
tab[index];
469 parent = heap->
tab[index / 2];
476 parent = heap->
tab[index / 2];
484 child_index = index * 2;
485 if (child_index >= heap->
len)
487 if (child_index == heap->
len - 1) {
540 while (!set->stopping) {
545 while (set->heap->len > 0 && set->heap->tab[0]->elapses <= now) {
556 if (set->heap->len == 0) {
560 top_time =
set->heap->tab[0]->elapses;
static void heap_insert(TimerHeap *heap, Timer *timer)
gw_assert(wtls_machine->packet_to_send !=NULL)
void gwlist_produce(List *list, void *item)
static TimerHeap * heap_create(void)
volatile sig_atomic_t stopping
static void heap_delete(TimerHeap *heap, long index)
void gwthread_join(long thread)
static void lock(Timerset *set)
void gwtimer_stop(Timer *timer)
static void heap_destroy(TimerHeap *heap)
void gwtimer_start(Timer *timer, int interval, WAPEvent *event)
void gwlist_remove_producer(List *list)
void gwtimer_destroy(Timer *timer)
static void elapse_timer(Timer *timer)
const char * wap_event_name(WAPEventName type)
long gwlist_delete_equal(List *list, void *item)
void warning(int err, const char *fmt,...)
void timers_shutdown(void)
#define gwthread_create(func, arg)
void gwthread_sleep(double seconds)
void mutex_destroy(Mutex *mutex)
WAPEvent * wap_event_duplicate(WAPEvent *event)
static void unlock(Timerset *set)
void debug(const char *place, int err, const char *fmt,...)
static int heap_adjust(TimerHeap *heap, long index)
static void heap_swap(TimerHeap *heap, long index1, long index2)
void gwthread_wakeup(long thread)
static void watch_timers(void *arg)
Timer * gwtimer_create(List *outputlist)
void gwlist_add_producer(List *list)
void wap_event_destroy(WAPEvent *event)
static void abort_elapsed(Timer *timer)