Example #1
0
void *
zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args)
{
    //  Create our end of the pipe
    //  Pipe has HWM of 1 at both sides to block runaway writers
    void *pipe = zsocket_new (ctx, ZMQ_PAIR);
    assert (pipe);
    zsockopt_set_hwm (pipe, 1);
    zsocket_bind (pipe, "inproc://zctx-pipe-%p", pipe);

    //  Prepare argument shim for child thread
    shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t));
    shim->attached = thread_fn;
    shim->args = args;
    shim->ctx = zctx_shadow (ctx);

    //  Connect child pipe to our pipe
    shim->pipe = zsocket_new (shim->ctx, ZMQ_PAIR);
    assert (shim->pipe);
    zsockopt_set_hwm (shim->pipe, 1);
    zsocket_connect (shim->pipe, "inproc://zctx-pipe-%p", pipe);

    s_thread_start (shim);
    return pipe;
}
Example #2
0
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);
    assert (pipe);
    zsocket_bind (pipe, "inproc://zctx-pipe-%p", pipe);

    //  Prepare argument shim for child thread
    shim = (shim_t *) zmalloc (sizeof (shim_t));
    assert (shim);
    shim->attached = thread_fn;
    shim->args = args;
    shim->ctx = zctx_shadow (ctx);
    assert (shim->ctx);
    shim->pipe = zctx__socket_pipe (shim->ctx);
    assert (shim->pipe);

    //  Connect child pipe to our pipe
    zsocket_connect (shim->pipe, "inproc://zctx-pipe-%p", pipe);

    s_thread_start (shim);
    return pipe;
}
Example #3
0
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 = zsocket_new (ctx, ZMQ_PAIR);
    if (pipe) {
        zsocket_set_hwm (pipe, zctx_hwm (ctx));
        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)
            return NULL;
    }
    else
        return NULL;
    
    //  Connect child pipe to our pipe
    shim->pipe = zsocket_new (shim->ctx, ZMQ_PAIR);
    if (!shim->pipe)
        return NULL;
    zsocket_set_hwm (shim->pipe, 1);
    zsocket_connect (shim->pipe, "inproc://zctx-pipe-%p", pipe);
    
    s_thread_start (shim);
    return pipe;
}
Example #4
0
void
zthread_new (zctx_t *ctx, zthread_detached_fn *thread_fn, void *args)
{
    //  Prepare argument shim for child thread
    shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t));
    shim->detached = thread_fn;
    shim->args = args;
    s_thread_start (shim);
}
Example #5
0
int
zthread_new (zthread_detached_fn *thread_fn, void *args)
{
    //  Prepare argument shim for child thread
    shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t));
    assert (shim);
    shim->detached = thread_fn;
    shim->args = args;
    s_thread_start (shim);
    return 0;
}