[zeromq-dev] Inproc Majordomo

Lucas Russo lerwys at gmail.com
Thu May 1 13:38:04 CEST 2014


>> I've been taking a look in the Majordomo protocol and the Github
>> implementation and I was thinking about the possibility to use it
>> for inproc zeroMQ nodes.
>>
>> With this I could have multiple threads exporting different services
>> to a broker, sharing the same context, and a low-level hardware access
>> layer (using PIPE sockets for inter-thread communication)
>>
>> 1) Does this makes sense as far as zeroMQ model is concerned?
>> 2) Could I have any problems regarding sharing the same context between
>> multiple threads using the Majordomo implementation?
>
> Service-based thread lookup is definitely an elegant model. You'd want
> all threads to share one context, to use inproc://
>
> You might use a simpler protocol. though using MDP means you can
> easily extend to external processes without change.
>
> -Pieter

Hi Pieter,

Would a patch to Majordomo to allow using it in multiple threads be useful?

I have something like the following:

mdp_worker_new (zctx_t *ctx, char *broker,char *service, int verbose)
{
    assert (broker);
    assert (service);

    mdp_worker_t *self = (mdp_worker_t *) zmalloc (sizeof (mdp_worker_t));

    if (ctx) {
        self->ctx = ctx;
        self->local_ctx = false;
    }
    else {
        self->ctx = zctx_new ();
        self->local_ctx = true;
    }

    ...
}

void
mdp_worker_destroy (mdp_worker_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        mdp_worker_t *self = *self_p;

        s_mdp_worker_send_to_broker (self, MDPW_DISCONNECT, NULL, NULL);

        if (self->local_ctx) {
            zctx_destroy (&self->ctx);
        }

        ...
    }

    ...
}

And altered a few other functions to take into account the new
self->local_ctx variable

Regards,

Lucas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140501/6049f9eb/attachment.htm>


More information about the zeromq-dev mailing list