Exemplo n.º 1
0
static void
sigint_callback(EV_P_ ev_signal *w, int revents)
{
    if (revents & EV_SIGNAL) {
        printf("Call signal_callback\n");
        printf("ev_async_send 调用前%d\n", ev_async_pending(&async_watcher));
        ev_async_send(EV_A, &async_watcher); //这里回调用async_callback
        printf("ev_async_send 调用后%d\n", ev_async_pending(&async_watcher));
    }
}
Exemplo n.º 2
0
static void accept_cb(struct ev_loop *loop, struct ev_io *w, int revents)
{
    int client_fd;
    struct sockaddr_in client_addr;
    socklen_t client_len = sizeof(client_addr);

    if (EV_ERROR & revents)
    {
        perror(" w got invalid event");
        return;
    }

    client_fd = accept(w->fd, (struct sockaddr *)&client_addr, &client_len);
    if (client_fd == -1) {
        return;
    }
    setnonblock(client_fd) ;
    if (!ev_async_pending(&async_watcher)) {
        pthread_mutex_lock(&lock);
        memset(&swap, 0, sizeof(swap));
        swap.fd = client_fd;
        swap.state = NOTINIT;
        swap.start_time = 1384227300;
        swap.in_used = 1;
        pthread_mutex_unlock(&lock);
        ev_async_send(work_loop, &async_watcher);
    }
}
Exemplo n.º 3
0
static PyObject *
Async_sent_get(Async *self, void *closure)
{
    PYEV_RETURN_BOOL(ev_async_pending(&self->async));
}