LaKraven / LKSL

LaKraven Studios Standard Library
http://otapi.com
Other
51 stars 15 forks source link

Make TLKEvent objects "Reference Counted" after dispatch #20

Closed LaKraven closed 9 years ago

LaKraven commented 9 years ago

This eliminates the need to provide a "Clone" method, saves significant amounts of memory (no need to create cloned instances of the same TLKEvent object) and improves performance (by not having to allocate and deallocate memory for TLKEvent clones within processing Threads).

It just... makes sense!

NOTE: I won't be using Interfaces to achieve this! The Event Engine NEEDS to use Class Methods to do what it does, and Interfaces don't support them!

LaKraven commented 9 years ago

A more simplistic approach may be to use an Interface (say "ILKEvent") to contain a property of "Event: TLKEvent" or "Event: T" depending on Generics capabilities). We then store the ILKEvent reference and pass that around. Once all the references are gone, the destructor of the ILKEvent-implementing class calls "Free" on the actual TLKEvent object.

Keep in mind that this is only necessary because we can't define class methods on an Interface type, and class methods are required for the way the Event Engine works.

LaKraven commented 9 years ago

Implemented as standard in the BigRedux branch's redevelopment of the Event Engine