예제 #1
0
int nn_worker_init(struct nn_worker *self)
{
    int32_t rc;
    //PostMessage("nn_worker_init %p\n",self);
    rc = nn_efd_init(&self->efd);
    //PostMessage("efd init: rc.%d\n",rc);
    if ( rc < 0 )
        return rc;
    //PostMessage("nn_mutex_init\n");
    nn_mutex_init(&self->sync);
    //PostMessage("nn_queue_init\n");
    nn_queue_init(&self->tasks);
    //PostMessage("nn_queue_item_init\n");
    nn_queue_item_init(&self->stop);
    //PostMessage("nn_poller_init\n");
    nn_poller_init(&self->poller);
    //PostMessage("nn_poller_add\n");
    nn_poller_add(&self->poller,nn_efd_getfd(&self->efd),&self->efd_hndl);
    //PostMessage("nn_poller_set_in\n");
    nn_poller_set_in(&self->poller, &self->efd_hndl);
    //PostMessage("nn_timerset_init\n");
    nn_timerset_init(&self->timerset);
    //PostMessage("nn_thread_init\n");
    nn_thread_init(&self->thread,nn_worker_routine, self);
    //PostMessage("finished nn_worker_init\n");
    return 0;
}
예제 #2
0
int nn_worker_init (struct nn_worker *self)
{
    int rc;

    rc = nn_efd_init (&self->efd);
    if (rc < 0)
        return rc;

    nn_mutex_init (&self->sync);
    nn_queue_init (&self->tasks);
    nn_queue_item_init (&self->stop);
    nn_poller_init (&self->poller);
    nn_poller_add (&self->poller, nn_efd_getfd (&self->efd), &self->efd_hndl);
    nn_poller_set_in (&self->poller, &self->efd_hndl);
    nn_timerset_init (&self->timerset);
    nn_thread_init (&self->thread, nn_worker_routine, self);

    return 0;
}