Esempio n. 1
0
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);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
ssize_t
syncsocket_write(SyncSocket* ssocket, const void* buf, size_t size, int timeout)
{
    return syncsocket_write_absolute(ssocket, buf, size, iolooper_now() + timeout);
}
Esempio n. 4
0
ssize_t
syncsocket_read(SyncSocket* ssocket, void* buf, size_t size, int timeout)
{
    return syncsocket_read_absolute(ssocket, buf, size, iolooper_now() + timeout);
}
Esempio n. 5
0
static Duration
glooper_now(Looper*  ll)
{
    return iolooper_now();
}
Esempio n. 6
0
                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