<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoPlainText>Message: 7<o:p></o:p></p><p class=MsoPlainText>Date: Sun, 17 Feb 2013 17:10:11 -0500<o:p></o:p></p><p class=MsoPlainText>From: Paul Coccoli <<a href="mailto:pcoccoli@gmail.com"><span style='color:windowtext;text-decoration:none'>pcoccoli@gmail.com</span></a>><o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>>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.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'>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)..<br><br><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>       </span><span style='font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white'>my_output_stream</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>& strm = MessageQueToGui();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>       strm << id_to_long(</span><span style='font-size:9.5pt;font-family:Consolas;color:#A31515;background:white;mso-highlight:white'>"mbox"</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>       strm << (</span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>int</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>) ( </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>sizeof</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>(</span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>wchar_t</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>) * </span><span style='font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white'>msg</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>.size() + </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>sizeof</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>(</span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>int</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>) + </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>sizeof</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>(icon</span><span style='font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white'>type</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>)); </span><span style='font-size:9.5pt;font-family:Consolas;color:green;background:white;mso-highlight:white'>// message length.</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>       strm << </span><span style='font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white'>msg</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>       strm << icon</span><span style='font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white'>type</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>;<o:p></o:p></span></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText><span style='color:black'>Jeff<o:p></o:p></span></p></div></body></html>