int iolooper_wait_absolute(IoLooper* iol, int64_t deadline) { int64_t timeout = deadline - iolooper_now(); /* If the deadline has passed, set the timeout to 0, this allows us * to poll the file descriptor nonetheless */ if (timeout < 0) timeout = 0; return iolooper_wait(iol, timeout); }
ssize_t syncsocket_read_line(SyncSocket* ssocket, char* buffer, size_t size, int timeout) { return syncsocket_read_line_absolute(ssocket, buffer, size, iolooper_now() + timeout); }
ssize_t syncsocket_write(SyncSocket* ssocket, const void* buf, size_t size, int timeout) { return syncsocket_write_absolute(ssocket, buf, size, iolooper_now() + timeout); }
ssize_t syncsocket_read(SyncSocket* ssocket, void* buf, size_t size, int timeout) { return syncsocket_read_absolute(ssocket, buf, size, iolooper_now() + timeout); }
static Duration glooper_now(Looper* ll) { return iolooper_now(); }
if (iolooper_is_write(iol, io->fd)) ready |= LOOP_IO_WRITE; io->ready = ready; if (ready != 0) { arefSet_add(looper->pendingIos, io); } }); } /* Do we have any expired timers here ? */ GLoopTimer* pendingTimers = NULL; GLoopTimer** pendingLastP = &pendingTimers; deadline = iolooper_now(); for (;;) { GLoopTimer* timer = looper->activeTimers; if (timer == NULL || timer->deadline > deadline) break; /* remove from active list, and append to pending one */ timer->deadline = DURATION_INFINITE; looper->activeTimers = timer->activeNext; *pendingLastP = timer; timer->activeNext = NULL; pendingLastP = &timer->activeNext; } /* Fire the pending timers, if any. We do that in a separate