Hi Christoph, I believe zeromq does this is by design. It copies the data if the message size is small and reference counts it if its above a certain size.
It looks like the size threshold is specified by the max_vsm_size enum in msg.hpp, currently set to 29, so if you make your message size 30 it should switch to reference counting. Regards, Richard. From: "Christoph Heindl" <[email protected]> To: [email protected] Date: 14/02/2013 07:38 AM Subject: [zeromq-dev] C++ Move Constructor and Assignment Operator Sent by: [email protected] Hi, I was using the Cpp ZMQ interface lately and while writing a bunch of unit tests I came accross curious behaviour in the move constructor and assignment operator of zmq::message_t. The following tests fail (zmq 3.2.2, latest zmq.hpp from github, MSVC10) zmq::message_t m0(10); void *adr = m0.data(); zmq::message_t m1; m1 = std::move(m0); BOOST_REQUIRE_EQUAL(adr, m1.data()); It might be a semantic error on my side, but I would have thought that an efficient implementation would happly reuse the buffer allocated by m0. Instead i get a different buffer address. Similarily the move constructor seems to re(a)locate the buffer zmq::message_t m0(10); void *adr = m0.data(); zmq::message_t m1(std::move(m0)); BOOST_REQUIRE_EQUAL(adr, m1.data()) Is this behaviour intended? Btw. in zmq.hpp std::swap is used in the move assignment operator. This seems to me as both buffers survive (at least temporarily) in a scenario as described above ( zmq::message_t m1(std::move(m0))). I guess that has something todo with the fact that closing the message is always done in the destructor. Best, Christoph_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev =========================================================== The information in this email is confidential, and is intended solely for the addressee(s). Access to this email by anyone else is unauthorized and therefore prohibited. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. ===========================================================
<<inline: graycol.gif>>
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
