Extracting underlying C context object
You can now use the Context:lightuserdata() method to get a light userdata pointer to the underlying ZeroMQ C context object. On the receiving end, the zmq.init() function can now take in a light userdata object, which creates a new Context object wrapper for an existing C context object. The main use case for this is to provide an easy way to pass a ZeroMQ context to another Lua interpreter. The two interpreters (which presumably would be running in separate threads) can then use ZeroMQ sockets from this context to communicate with each other. In this use case, we have to be sure not call zmq_term in the Context __gc metamethod, since both Lua interpreters would try to do this. Internally, we keep an additional boolean field that indicates whether a Context object is responsible for terminating the context. When created with a light userdata, this will be false. When created normally, the default is true, but can be overridden.lua-zmq^2
parent
5158c5fe44
commit
1b1191a3be
Loading…
Reference in New Issue