* io_time_override - override the normal call for time.
* @nowfn: the function to call.
*
- * io usually uses time_now() internally, but this forces it
+ * io usually uses time_mono() internally, but this forces it
* to use your function (eg. for debugging). Returns the old
* one.
*/
-struct timeabs (*io_time_override(struct timeabs (*now)(void)))(void);
+struct timemono (*io_time_override(struct timemono (*now)(void)))(void);
/**
* io_set_debug - set synchronous mode on a connection.
static struct fd **fds = NULL;
static LIST_HEAD(closing);
static LIST_HEAD(always);
-static struct timeabs (*nowfn)(void) = time_now;
+static struct timemono (*nowfn)(void) = time_mono;
-struct timeabs (*io_time_override(struct timeabs (*now)(void)))(void)
+struct timemono (*io_time_override(struct timemono (*now)(void)))(void)
{
- struct timeabs (*old)(void) = nowfn;
+ struct timemono (*old)(void) = nowfn;
nowfn = now;
return old;
}
assert(num_waiting);
if (timers) {
- struct timeabs now, first;
+ struct timemono now, first;
now = nowfn();
/* Now figure out how long to wait for the next one. */
if (timer_earliest(timers, &first)) {
uint64_t next;
- next = time_to_msec(time_between(first, now));
+ next = time_to_msec(timemono_between(first, now));
if (next < INT_MAX)
ms_timeout = next;
else
d->conn = conn;
io_set_finish(conn, finish_ok, d);
- timer_add(&d->timers, &d->timer,
- timeabs_add(time_now(), time_from_usec(d->timeout_usec)));
+ timer_addrel(&d->timers, &d->timer, time_from_usec(d->timeout_usec));
return io_read(conn, d->buf, sizeof(d->buf), no_timeout, d);
}
plan_tests(21);
d->state = 0;
d->timeout_usec = 100000;
- timers_init(&d->timers, time_now());
+ timers_init(&d->timers, time_mono());
timer_init(&d->timer);
fd = make_listen_fd(PORT, &addrinfo);
ok1(fd >= 0);
/* One element, d->timer. */
ok1(expired == &d->timer);
- ok1(!timers_expire(&d->timers, time_now()));
+ ok1(!timers_expire(&d->timers, time_mono()));
ok1(d->state == 1);
io_close(d->conn);
return fd;
}
-static struct timeabs fake_time;
+static struct timemono fake_time;
-static struct timeabs get_fake_time(void)
+static struct timemono get_fake_time(void)
{
return fake_time;
}
/* This is how many tests you plan to run */
plan_tests(7);
- fake_time = time_now();
+ fake_time = time_mono();
timers_init(&timers, fake_time);
timer_init(&timer);
- timer_add(&timers, &timer,
- timeabs_add(fake_time, time_from_sec(1000)));
+ timer_addmono(&timers, &timer,
+ timemono_add(fake_time, time_from_sec(1000)));
fd = make_listen_fd(PORT, &addrinfo);
freeaddrinfo(addrinfo);
ok1(l);
fake_time.ts.tv_sec += 1000;
- ok1(io_time_override(get_fake_time) == time_now);
+ ok1(io_time_override(get_fake_time) == time_mono);
ok1(io_loop(&timers, &expired) == NULL);
ok1(expired == &timer);
ok1(!timers_expire(&timers, fake_time));
- ok1(io_time_override(time_now) == get_fake_time);
+ ok1(io_time_override(time_mono) == get_fake_time);
io_close_listener(l);
timers_cleanup(&timers);