예제 #1
0
파일: zctx.c 프로젝트: dnaeon/czmq
void
zctx_destroy (zctx_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zctx_t *self = *self_p;
        while (zlist_size (self->sockets))
            zctx__socket_destroy (self, zlist_first (self->sockets));
        zlist_destroy (&self->sockets);
        if (self->main && self->context)
            zmq_term (self->context);
        free (self);
        *self_p = NULL;
    }
}
예제 #2
0
파일: zthread.c 프로젝트: Lucky7Studio/czmq
void *
zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args)
{
    shim_t *shim = NULL;
    //  Create our end of the pipe
    void *pipe = zctx__socket_pipe (ctx);
    if (pipe)
        zsocket_bind (pipe, "inproc://zctx-pipe-%p", pipe);
    else
        return NULL;
    
    //  Prepare argument shim for child thread
    shim = (shim_t *) zmalloc (sizeof (shim_t));
    if (shim) {
        shim->attached = thread_fn;
        shim->args = args;
        shim->ctx = zctx_shadow (ctx);
        if (!shim->ctx) {
            zctx__socket_destroy (ctx, pipe);
            return NULL;
        }
    }
    else
        return NULL;
    
    //  Connect child pipe to our pipe
    shim->pipe = zctx__socket_pipe (shim->ctx);
    if (!shim->pipe) {
        zctx__socket_destroy (ctx, pipe);
        return NULL;
    }
    zsocket_connect (shim->pipe, "inproc://zctx-pipe-%p", pipe);
    
    s_thread_start (shim);
    return pipe;
}
예제 #3
0
파일: zctx.c 프로젝트: calid/czmq
void
zctx_destroy (zctx_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zctx_t *self = *self_p;

        //  Destroy all sockets
        while (zlist_size (self->sockets))
            zctx__socket_destroy (self, zlist_first (self->sockets));
        zlist_destroy (&self->sockets);
        zmutex_destroy (&self->mutex);

        //  ZMQ context may not yet be instantiated
        if (self->context && !self->shadow)
            zmq_term (self->context);

        free (self);
        *self_p = NULL;
    }
}
예제 #4
0
파일: zsocket.c 프로젝트: AxelVoitier/czmq
void
zsocket_destroy (zctx_t *ctx, void *self)
{
    if (self)
        zctx__socket_destroy (ctx, self);
}
예제 #5
0
파일: zsocket.c 프로젝트: ohye4tt/czmq
void
zsocket_destroy (zctx_t *ctx, void *socket)
{
    zctx__socket_destroy (ctx, socket);
}
예제 #6
0
파일: zsocket.c 프로젝트: sponsored/czmq
void
zsocket_destroy (zctx_t *ctx, void *zocket)
{
    if (zocket)
        zctx__socket_destroy (ctx, zocket);
}