Explicitly driven garbage collector. More...
#include <Maid.hpp>
Public Member Functions | |
Maid (size_t size) | |
void | push (Raul::Deletable *obj) |
Push a raw pointer to be deleted when cleanup() is called next. | |
void | manage (SharedPtr< Raul::Deletable > ptr) |
Manage a SharedPtr. | |
void | cleanup () |
Free all the objects in the queue (passed by push()). |
Explicitly driven garbage collector.
This is used by realtime threads to allow hard realtime deletion of objects (push() is realtime safe).
You can also manage a SharedPtr, so cleanup() will delete it when all references are dropped (except the one held by the Maid itself). This allows using a SharedPtr freely in hard realtime threads without having to worry about deletion accidentally occuring in the realtime thread.
cleanup() should be called periodically to free memory, often enough to prevent the queue from overflowing. This is probably best done by the main thread to avoid the overhead of having a thread just to delete things.
void Raul::Maid::push | ( | Raul::Deletable * | obj | ) | [inline] |
Push a raw pointer to be deleted when cleanup() is called next.
Realtime safe.
void Raul::Maid::manage | ( | SharedPtr< Raul::Deletable > | ptr | ) |
Manage a SharedPtr.
NOT realtime safe.
ptr is guaranteed to be deleted in the context that calls cleanup()