Exemple #1
0
int main(int argc, char *argv[])
{
    int i;

    Dispatcher *dis = disCreate();

    pipe(fd);

    disOnData(dis, fd[0], handle_fd0, NULL);
    disOnTime(dis, nowd() + 0.1, handle_timeout, NULL);

    for (i = 0; i < fd[0]; i++) {
        make_sure_that(!disOwnsFd(dis, i));
    }

    make_sure_that(disOwnsFd(dis, fd[0]));

    disRun(dis);

    return errors;
}
Exemple #2
0
/*
 * Arrange for <cb> to be called at time <t>, which is the (double precision floating point) number
 * of seconds since 00:00:00 UTC on 1970-01-01 (aka. the UNIX epoch). <cb> will be called with the
 * given <ns>, <t> and <udata>. You can get the current time using nowd() from utils.c.
 */
void nsOnTime(NS *ns, double t, void (*cb)(NS *ns, double t, void *udata), const void *udata)
{
    disOnTime(&ns->dis, t, (void(*)(Dispatcher *dis, double t, void *udata)) cb, udata);
}