Example #1
0
static void routine2 (NN_UNUSED void *arg)
{
    int s;
    int i;

    s = test_socket (AF_SP, NN_PULL);

    for (i = 0; i < 10; ++i) {
        test_connect (s, SOCKET_ADDRESS);
    }

    for (i = 0; i < MESSAGES_PER_THREAD; ++i) {
        test_recv (s, "hello");
    }

    test_close (s);
    nn_atomic_dec(&active, 1);
}
Example #2
0
void nn_chunk_free (struct nn_chunk *self)
{
    nn_assert (self->tag == NN_CHUNK_TAG);

    /*  Decrement the reference count. Actual deallocation happens only if
        it drops to zero. */
    if (nn_atomic_dec (&self->refcount, 1) <= 1) {
        
        /*  Mark chunk as deallocated. */
        self->tag = 0;

        nn_atomic_term (&self->refcount);

        /*  Compute the beginning of the allocated block and deallocate it
            according to the allocation mechanism specified. */
        self->vfptr->free (((uint8_t*) self) - self->offset);
    }
}
Example #3
0
void nn_chunk_free (void *p)
{
    struct nn_chunk *self;

    self = nn_chunk_getptr (p);

    /*  Decrement the reference count. Actual deallocation happens only if
        it drops to zero. */
    if (nn_atomic_dec (&self->refcount, 1) <= 1) {
        
        /*  Mark chunk as deallocated. */
        nn_putl ((uint8_t*) (((uint32_t*) p) - 1), NN_CHUNK_TAG_DEALLOCATED);

        /*  Deallocate the resources held by the chunk. */
        nn_atomic_term (&self->refcount);

        /*  Deallocate the memory block according to the allocation
            mechanism specified. */
        self->ffn (self);
    }
}