On Sat, 2011-08-20 at 10:04 -0500, Gabriel Beddingfield wrote:
The main issue you'll find with going the C++/RTTI route is that #2 no
longer is possible, since virtual objects are not POD, so you can't
safely write them through a ringbuffer (or copy them around manually in
You can, of course, copy around *pointers* to them. This means you have
to dynamically allocate them. If you want to be able to create events in
a real-time thread, you will have to get into more advanced C++ and make
a custom allocator for that etc. etc.
In short, be wary of going too far in the C++/new/RTTI/virtual route for
events. It's not necessarily a bad solution, but if you might want to do
a bit more fancy things like send events through a pipe some day, it's
not what you want to do. There's a lot to be said for POD events.
Also, this is odd:
> class event_two_t : public event_t
If you're going to go with the inheritance route anyway, just use a
virtual ev->execute() method so the code for all events doesn't have to
be in the same place. Assuming you'll have enough that this is actually
a benefit anyway...
Linux-audio-dev mailing list