[zeromq-dev] ØMQ VSM data alignment

Matt Weinstein matt_weinstein at yahoo.com
Wed Aug 4 20:27:17 CEST 2010


First thing zmq does is close the old message:

e.g.
rep.cpp : 190

   // Deallocate old content of the message.
     zmq_msg_close (msg_);

On Aug 4, 2010, at 2:19 PM, Jon Dyte wrote:

> Matt Weinstein wrote:
>>
>>
>> On Aug 4, 2010, at 1:37 PM, Andrew Hume wrote:
>>
>>> this sort of thing can get problematic quickly.
>>> the combinatorial explosion of cache-line design, memory design,
>>> language alignment rules, architectures allowing non-aligned  
>>> references
>>> (but punishing you with slowness) makes testing hard.
>>>
>>> on the other hand, starting on a 8 byte boundary is always a good
>>> idea in modern architectures.
>>>
>>> better style is to use a byte stream so you won't get bitten by
>>> LSB/MSB issues
>>> or packets coming from other machine architectures.
>>>
>>
>> Yes, but I want to do this:
>>
>>    zmq::message_t foo;
>>
>>    s.recv(&foo);
>>    my_struct const* pstruct = reinterpret_cast<my_struct
>> const*>(foo.data());
>>
>>    cout << "Works like magic: " << pstruct->member << ". All your
>> processor are belong to Intel! (*)" << endl;
>>
>> That's the no-copy approach :-)
>>
>> I can do it with malloc() without issue or penalty...
>>
>> (*) There are no other architectures :-)
>>
>
>
> I havent ever tried, but does this not work?
>
>    my_struct ms;
>    zmq::message_t foo(&ms, sizeof(my_struct), NULL, NULL);
>    s.recv(&foo);
>
>    // now i think here you would have to to check the size was sizeof
> my_struct. and the data() is indeed the address of ms.
>
>
>
> Jon
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev




More information about the zeromq-dev mailing list