Exemplo n.º 1
0
MgErr ftw_nanomsg_reserve(struct ftw_socket_callsite **inst)
{
    static int callsite = 0;

    /*  Preconditions expected of LabVIEW. */
    ftw_assert(inst);

    /*  Creates a list of socket instances for each CLFN callsite. */
    if (*inst == NULL) {
        callsite++;
        ftw_debug("Reserving Socket Creation Callsite %d", callsite);
        *inst = ftw_malloc(sizeof(struct ftw_socket_callsite));
        ftw_assert(*inst);
        nn_mutex_init(&(*inst)->sync);
        nn_mutex_lock(&(*inst)->sync);
        nn_list_init(&(*inst)->active_sockets);
        (*inst)->id = callsite;
        (*inst)->lifetime_sockets = 0;
        nn_mutex_unlock(&(*inst)->sync);
    }
    else {
        ftw_assert_unreachable("Reserve happened twice; this is a problem with LabVIEW.");
    }

    return mgNoErr;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
void nn_atomic_init (struct nn_atomic *self, uint32_t n)
{
    self->n = n;
#if defined NN_ATOMIC_MUTEX
    nn_mutex_init (&self->sync);
#endif
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
void nn_alloc_init (void)
{
    nn_mutex_init (&nn_alloc_sync);
    nn_alloc_bytes = 0;
    nn_alloc_blocks = 0;
}
Exemplo n.º 6
0
Arquivo: ins.c Projeto: 4ker/nanomsg
void nn_ins_init (void)
{
    nn_mutex_init (&self.sync);
    nn_list_init (&self.bound);
    nn_list_init (&self.connected);
}