static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) {
    AvahiTimeout *t;
    AvahiSimplePoll *s;

    assert(api);
    assert(callback);

    s = api->userdata;
    assert(s);

    if (!(t = avahi_new(AvahiTimeout, 1)))
        return NULL;

    /* If there is a background thread running the poll() for us, tell it to exit the poll() */
    avahi_simple_poll_wakeup(s);

    t->simple_poll = s;
    t->dead = 0;

    if ((t->enabled = !!tv))
        t->expiry = *tv;

    t->callback = callback;
    t->userdata = userdata;

    AVAHI_LLIST_PREPEND(AvahiTimeout, timeouts, s->timeouts, t);
    return t;
}
static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata) {
    AvahiWatch *w;
    AvahiSimplePoll *s;

    assert(api);
    assert(fd >= 0);
    assert(callback);

    s = api->userdata;
    assert(s);

    if (!(w = avahi_new(AvahiWatch, 1)))
        return NULL;

    /* If there is a background thread running the poll() for us, tell it to exit the poll() */
    avahi_simple_poll_wakeup(s);

    w->simple_poll = s;
    w->dead = 0;

    w->pollfd.fd = fd;
    w->pollfd.events = event;
    w->pollfd.revents = 0;

    w->callback = callback;
    w->userdata = userdata;

    w->idx = -1;
    s->rebuild_pollfds = 1;

    AVAHI_LLIST_PREPEND(AvahiWatch, watches, s->watches, w);
    s->n_watches++;

    return w;
}
void avahi_simple_poll_quit(AvahiSimplePoll *s) {
    assert(s);

    s->quit = 1;

    /* If there is a background thread running the poll() for us, tell it to exit the poll() */
    avahi_simple_poll_wakeup(s);
}
void avahi_simple_poll_set_func(AvahiSimplePoll *s, AvahiPollFunc func, void *userdata) {
    assert(s);

    s->poll_func = func ? func : system_poll;
    s->poll_func_userdata = func ? userdata : NULL;

    /* If there is a background thread running the poll() for us, tell it to exit the poll() */
    avahi_simple_poll_wakeup(s);
}
static void timeout_free(AvahiTimeout *t) {
    assert(t);
    assert(!t->dead);

    /* If there is a background thread running the poll() for us, tell it to exit the poll() */
    avahi_simple_poll_wakeup(t->simple_poll);

    t->dead = 1;
    t->simple_poll->timeout_req_cleanup = 1;
}
static void timeout_update(AvahiTimeout *t, const struct timeval *tv) {
    assert(t);
    assert(!t->dead);

    /* If there is a background thread running the poll() for us, tell it to exit the poll() */
    avahi_simple_poll_wakeup(t->simple_poll);

    if ((t->enabled = !!tv))
        t->expiry = *tv;
}
static void watch_free(AvahiWatch *w) {
    assert(w);

    assert(!w->dead);

    /* If there is a background thread running the poll() for us, tell it to exit the poll() */
    avahi_simple_poll_wakeup(w->simple_poll);

    remove_pollfd(w);

    w->dead = 1;
    w->simple_poll->n_watches --;
    w->simple_poll->watch_req_cleanup = 1;
}
static void watch_update(AvahiWatch *w, AvahiWatchEvent events) {
    assert(w);
    assert(!w->dead);

    /* If there is a background thread running the poll() for us, tell it to exit the poll() */
    avahi_simple_poll_wakeup(w->simple_poll);

    w->pollfd.events = events;

    if (w->idx != -1) {
        assert(w->simple_poll);
        w->simple_poll->pollfds[w->idx] = w->pollfd;
    } else
        w->simple_poll->rebuild_pollfds = 1;
}
Exemple #9
0
void wxAvahiSimplePool::WakeUp(){
    avahi_simple_poll_wakeup(m_pool);
}