Reputation: 1372
ZeroCopy messaging is something that can be implemented in zeromq, but is it possible to use it with the zmqpp c++ bindings? There is almost no documentation, and I was not able to find anything in the examples...
Upvotes: 2
Views: 1352
Reputation: 59
Just simply use zmqpp::message::copy().
In the zmqpp source code we can see:
void message::copy(message const& source)
{
_parts.resize( source._parts.size() );
for(size_t i = 0; i < source._parts.size(); ++i)
{
_parts[i] = source._parts[i].copy();
}
// we don't need a copy of the releasers as we did data copies of the internal data,
//_releasers = source._releasers;
//_strings = source._strings
}
the _parts which defined as:
private:
typedef std::vector<frame> parts_type;
parts_type _parts;
so, source._parts[i].copy() actually call zmqpp::frame::copy() which defined here:
frame frame::copy() const
{
frame other( size() );
other._sent = _sent;
if( 0 != zmq_msg_copy( &other._msg, const_cast<zmq_msg_t*>(&_msg) ) )
{
throw zmq_internal_exception();
}
return other;
}
zmqpp::frame::_msg in the code snippet is defined as zmq_msg_t. All zmq_msg_t object in the frame objects of source zmqpp::message object been zero copied by zmq_msg_copy to new zmqpp::message object.
so, zmqpp::message::copy() help us get a new zmqpp::message object which it's all frame is zero copied from the source zmqpp::message object.
Upvotes: 0
Reputation: 1042
I would switch to cppzmq.
It's a more active project and maintained by some of the core libzmq people.
It's header only and has support for zero copy.
Upvotes: 2