• Jens Auer's avatar
    Allocation-free msg::init_data · 611e96c7
    Jens Auer authored
    With a msg_t size of 64 bytes, it becomes possible to embedd the content_t's members
    struct for large messages directly in the msg_t. This saves the dynamic allocation
    of content_t obejcts when using msg_t::init_data.
    
    content_t contains a zmq::atomic_counter_t object which is not a POD in C++98
    and thus it cannot be used as a member of the union u. To bypass this, C++11
    is used which has relaxed rules for POD and atomic_counter is a C++11-POD. An
    alternative would have been to make atomic_counter a classical POD by removing
    constructors and all private member functions, i.e. have a struct and free functions
    to manipulate it.
    
    A new msg_t::init function is added which decides to either to copy the data for size<64 bytes
    or use msg_t::init_data to do zero-copy initialization.
    611e96c7
msg.hpp 7.73 KB