<div class="gmail_quote">On Thu, Sep 1, 2011 at 7:18 PM, David Robillard <span dir="ltr"><<a href="mailto:d@drobilla.net">d@drobilla.net</a>></span> wrote:</div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">The main issue you'll find with going the C++/RTTI route is that #2 no<br>longer is possible, since virtual objects are not POD, so you can't<br>
safely write them through a ringbuffer (or copy them around manually in<br>general).</span></blockquote><div>True, I'm currently just adding functions to an existing class, rather than the subclassing option. That makes reading / writing the class to/from a ringbuffer easier, as they're all the same size... For performance I'm aware that its causing extra work, but for simplicity I'm going to keep it this way :D</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">The uglest bit of having one class is having a fixed amount of variables, and only some are being used. I've circumvented madness by creating set() functions, that initialize the "type" variable, and also takes the right parameters for that event type & stores them in the class. Does mean that there's some pointless data being transferred into / outta the JACK thread using the ringbuffers... oh well!</div>
<div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
You can, of course, copy around *pointers* to them. This means you have<br>
to dynamically allocate them. If you want to be able to create events in<br>
a real-time thread, you will have to get into more advanced C++ and make<br>
a custom allocator for that etc. etc.<br></blockquote><div><br></div><div>Pointers: That's exactly what I'm doing... and I do need to dynamically allocate them too... so I decided to do that in a non-RT thread, and have a ringbuffer of new events, and a ringbuffer of valid events, where the JACK RT thread can pull one of the Events from the "store" of new events, and then fill it in in a RT context, and then push that pointer onto the other ringbuffer that's going to be processed in another non-RT context... It might be a little more complex than needed, but its serving my purposes now :)</div>
<div><br></div><div>Passing strings around isn't possible due to the nature of strdup(), so I've enumerated all the messagesthat the JACK thread might need to send, and then have a big switch to handle all the different error messages. Not very nice but its RT safe. I've done the same for sending the PATH and SIGNATURE elements of OSC messages.</div>
<div><br></div><div>Functors & closures, yeah I suppose... for now this system is working, and quite easy to add new types to (does need a big recompile after a change though.. as heaps of headers include the "Event" type, as its pretty much to core of the Engine.. :)</div>
<div><br></div><div>-Harry</div><div><br></div><div>PS: Nice article on "Duct tape programming": <a href="http://www.joelonsoftware.com/items/2009/09/23.html">http://www.joelonsoftware.com/items/2009/09/23.html</a> Especially read the paragraph beside the photo of the guy jumping</div>
</div>