[Tdg] overloading new puzzle
Wesley Smith
wesley.hoke at gmail.com
Sat Aug 4 15:05:42 PDT 2007
So I have a functioning system right now. Here's how it works:
For each event class, I'm creating a static instance of the class.
For creating new events, there's an EventFactory that has an internal
memory pool. It does a sizeof() on the event type to be created and
allocates that much memory from the pool. It then hands off the
uninitialized memory to the event class' static void create(Event *e);
method. This does a memcpy (and yes it works) to initialize the
memory.
This event is then sent off to a central hub where it is distributed
to the appropriate queue. when the queue is done with the event it
class Event::recycle() which sends it back to the factory for
recycling the memory back into its memory pool.
This is all threadsafe to boot. I'm about to test is with sending OSC
messages from one thread to a graphics thread and see how things pan
out, but my test code (which is single threaded right now) shows
things to be working well.
There are some design issues about API we need to discuss like what
defines a mint::Object or a mint::Event. Are they threadsafe? Have a
memory pool? I think there is a very strong need for an EventFactory
so how tightly is EventFactory coupled with Event? How is reference
counting of Events done? How can one event be sent to multiple
places? Is this even necessary?
Once I get the networking test done, I'll try and summarize the design
and potential issues for discussion in a more formal manner and put
this stuff in SVN.
wes
More information about the Tdg
mailing list