EventAnalysis
1.3.0
|
A tracker class for data objects. More...
#include <RemovedObjectsTracker.h>
Classes | |
struct | ProducerHandler |
Public Member Functions | |
bool | TrackObject (const std::string &name, const observer_ptr< ObjectProducer > &producer) |
Adds an object and its producer to the tracked objects list. More... | |
void | RemoveObject (const std::string &name) |
Flags an object as removed. More... | |
void | UntrackObject (const std::string &name) |
Remove an object from the list of tracked objects. More... | |
bool | FreeRemoved (Memory::Status memStatus) |
Releases the memory allocated for removed objects. More... | |
void | Clean () |
Empties the list of tracked objects and producers. More... | |
Protected Attributes | |
std::vector< ProducerHandler > | _producerHandlers |
A tracker class for data objects.
This class keeps track of objects added and removed from a data store. Removed objects and their producers are tracked, so that in a memory pressure situation a memory release for removed objects can be triggered.
void EA::RemovedObjectsTracker::Clean | ( | ) |
Empties the list of tracked objects and producers.
This method removes all the producer-object pairs added by #AddObjects, and cleans also the list of removed objects (so that a subsequent call to FreeRemoved will have no effect).
bool EA::RemovedObjectsTracker::FreeRemoved | ( | Memory::Status | memStatus | ) |
Releases the memory allocated for removed objects.
This method asks all the object producers to free the memory of the removed objects they produced. The memStatus
memory status code is passed to each producer, that can decide to which degree perform the memory release based on the status code. If the status code is Memory::Status::EXHAUSTED then the producers are required to free all of their removed objects.
memStatus | The memory status code. |
void EA::RemovedObjectsTracker::RemoveObject | ( | const std::string & | name | ) |
Flags an object as removed.
The memory of removed objects can be released by calling FreeRemoved.
name | The name of the removed object. |
bool EA::RemovedObjectsTracker::TrackObject | ( | const std::string & | name, |
const observer_ptr< ObjectProducer > & | producer | ||
) |
Adds an object and its producer to the tracked objects list.
This method store a reference between an object and its producer, so that when the object is removed by RemoveObject it can be flagged for memory release.
name | The name of the object. |
producer | Pointer to the producer of the object. |
void EA::RemovedObjectsTracker::UntrackObject | ( | const std::string & | name | ) |
Remove an object from the list of tracked objects.
By calling this method, a previously tracked object will be removed from the list of tracking list, so that e.g. no memory deallocation for it will be triggered by FreeRemoved. This method can be called either for removed or for non-removed objects (
name | The object to untrack. |
|
protected |