[zeromq-dev] Inproc Majordomo

Pieter Hintjens ph at imatix.com
Thu May 1 16:26:10 CEST 2014


You can make any patches to the majordomo code you feel useful...

I'm actually working on removing contexts entirely from our codebase
(CZMQ and higher).

On Thu, May 1, 2014 at 1:38 PM, Lucas Russo <lerwys at gmail.com> wrote:
>>> 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
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list