My tests do this in the same file: { # test case 1 my $ctxt = ZeroMQ::Context->new(); # internally calls zmq_init(); ... test code here .... } # contxt freed
{ # test case 2 my $ctxt = ZeroMQ::Context->new(); # internally calls zmq_init(); ... test code here .... } # contxt freed should this work? And how about when you fork? Who should own the context? the parent? the child? or should it be shared? --d 2010/9/14 Martin Sustrik <sust...@250bpm.com>: > Hi Pieter, > > One frequent misuse of 0MQ is that newbies tend to open multiple context > objects with no apparent reason. > > What about explaining the correct usage in the user guide? > > The _only_ use case for multiple contexts is this one: > > Person A writes a library using 0MQ. Person B writes another library > using 0MQ. Person C links both libraries to his application. If each > haven't had a separate context the two 0MQ instances would clash. Name > clashes in the shared namespace for inproc endpoints. How many I/O > threads to launch, A's amount or B's amount? etc. > > In short: If you are writing an application use _one_ context object. > Another context object can arrive in the process only by linking with a > different application. > > Martin > _______________________________________________ > zeromq-dev mailing list > zeromq-dev@lists.zeromq.org > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > _______________________________________________ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev