Message: 7

Date: Sun, 17 Feb 2013 17:10:11 -0500

From: Paul Coccoli <pcoccoli@gmail.com>

 

>You're effectively serializing your object and passing them over the ringbuffer.  If you do it this way, you should at least consider explicitly embedding the type and length as the first member of EventBase (and have each derived class set their own type and length in their constructors), and reading those before touching the object you read.

 

Very good, that's what I do. The event is serialised to the ringbuffer, one member at a time (so I don't rely on a particular memory layout, or padding. The Type of message and the length are the first two values. (this example sends some text to the GUI to display a message box)..

       my_output_stream& strm = MessageQueToGui();

 

       strm << id_to_long("mbox");

       strm << (int) ( sizeof(wchar_t) * msg.size() + sizeof(int) + sizeof(icontype)); // message length.

       strm << msg;

       strm << icontype;

 

 

Jeff