if (read(u->fd, &fired, sizeof(fired)) != sizeof(fired))
return;
- struct uloop_interval *tm = container_of(u, struct uloop_interval, private.ufd);
+ struct uloop_interval *tm = container_of(u, struct uloop_interval, priv.ufd);
tm->expirations += fired;
tm->cb(tm);
static int timer_register(struct uloop_interval *tm, unsigned int msecs)
{
- if (!tm->private.ufd.registered) {
+ if (!tm->priv.ufd.registered) {
int fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC|TFD_NONBLOCK);
if (fd == -1)
return -1;
- tm->private.ufd.fd = fd;
- tm->private.ufd.cb = dispatch_timer;
+ tm->priv.ufd.fd = fd;
+ tm->priv.ufd.cb = dispatch_timer;
}
struct itimerspec spec = {
}
};
- if (timerfd_settime(tm->private.ufd.fd, 0, &spec, NULL) == -1)
+ if (timerfd_settime(tm->priv.ufd.fd, 0, &spec, NULL) == -1)
goto err;
- if (uloop_fd_add(&tm->private.ufd, ULOOP_READ) == -1)
+ if (uloop_fd_add(&tm->priv.ufd, ULOOP_READ) == -1)
goto err;
return 0;
err:
- uloop_fd_delete(&tm->private.ufd);
- close(tm->private.ufd.fd);
- memset(&tm->private.ufd, 0, sizeof(tm->private.ufd));
+ uloop_fd_delete(&tm->priv.ufd);
+ close(tm->priv.ufd.fd);
+ memset(&tm->priv.ufd, 0, sizeof(tm->priv.ufd));
return -1;
}
static int timer_remove(struct uloop_interval *tm)
{
- int ret = __uloop_fd_delete(&tm->private.ufd);
+ int ret = __uloop_fd_delete(&tm->priv.ufd);
if (ret == 0) {
- close(tm->private.ufd.fd);
- memset(&tm->private.ufd, 0, sizeof(tm->private.ufd));
+ close(tm->priv.ufd.fd);
+ memset(&tm->priv.ufd, 0, sizeof(tm->priv.ufd));
}
return ret;
{
struct itimerspec spec;
- if (!tm->private.ufd.registered)
+ if (!tm->priv.ufd.registered)
return -1;
- if (timerfd_gettime(tm->private.ufd.fd, &spec) == -1)
+ if (timerfd_gettime(tm->priv.ufd.fd, &spec) == -1)
return -1;
return spec.it_value.tv_sec * 1000 + spec.it_value.tv_nsec / 1000000;
if (events[n].filter == EVFILT_TIMER) {
struct uloop_interval *tm = events[n].udata;
- tm->private.time.fired = get_timestamp_us();
+ tm->priv.time.fired = get_timestamp_us();
tm->expirations += events[n].data;
tm->cb(tm);
{
struct kevent ev;
- tm->private.time.msecs = msecs;
- tm->private.time.fired = get_timestamp_us();
+ tm->priv.time.msecs = msecs;
+ tm->priv.time.fired = get_timestamp_us();
EV_SET(&ev, (uintptr_t)tm, EVFILT_TIMER, EV_ADD, NOTE_USECONDS, msecs * 1000, tm);
static int64_t timer_next(struct uloop_interval *tm)
{
- int64_t t1 = tm->private.time.fired;
+ int64_t t1 = tm->priv.time.fired;
int64_t t2 = get_timestamp_us();
while (t1 < t2)
- t1 += tm->private.time.msecs * 1000;
+ t1 += tm->priv.time.msecs * 1000;
return (t1 - t2) / 1000;
}