#undef LOCAL_DEBUG
-#include "ucw/lib.h"
-#include "ucw/heap.h"
-#include "ucw/mainloop.h"
-#include "ucw/threads.h"
-#include "ucw/gary.h"
-#include "ucw/process.h"
+#include <ucw/lib.h>
+#include <ucw/heap.h>
+#include <ucw/mainloop.h>
+#include <ucw/threads.h>
+#include <ucw/gary.h>
+#include <ucw/process.h>
+#include <ucw/time.h>
#include <stdio.h>
#include <string.h>
static void
main_get_time_ctx(struct main_context *m)
{
- struct timeval tv;
- gettimeofday(&tv, NULL);
- m->now_seconds = tv.tv_sec;
- m->now = (timestamp_t)tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ m->now = get_timestamp();
}
static struct main_context *
{
tm->expires = expires;
tm->index = num_timers + 1;
- *GARY_PUSH(m->timer_table, 1) = tm;
- HEAP_INSERT(struct main_timer *, m->timer_table, tm->index, MAIN_TIMER_LESS, MAIN_TIMER_SWAP);
+ GARY_RESIZE(m->timer_table, num_timers + 2);
+ HEAP_INSERT(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm);
}
else
{
tm->expires = expires;
- HEAP_INCREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index);
+ HEAP_INCREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index, tm);
}
}
else if (tm->expires > expires)
else
{
tm->expires = expires;
- HEAP_DECREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index);
+ HEAP_DECREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index, tm);
}
}
}