simgrid::instr::Container::~Container()
{
XBT_DEBUG("destroy container %s", name_.c_str());
+ // Begin with destroying my own children
+ for (auto child : children_) {
+ delete child.second;
+ }
- // obligation to dump previous events because they might
- // reference the container that is about to be destroyed
+ // obligation to dump previous events because they might reference the container that is about to be destroyed
TRACE_last_timestamp_to_dump = surf_get_clock();
TRACE_paje_dump_buffer(1);
LogContainerDestruction(this);
}
- // remove it from allContainers data structure
+ // remove me from the allContainers data structure
allContainers.erase(name_);
-
- // free
}
simgrid::instr::Container* PJ_container_get(const char* name)
parent->children_.erase(child->name_);
}
}
-
-static void recursiveDestroyContainer (container_t container)
-{
- if (container == nullptr){
- THROWF (tracing_error, 0, "trying to recursively destroy a nullptr container");
- }
- XBT_DEBUG("recursiveDestroyContainer %s", container->name_.c_str());
- for (auto child : container->children_) {
- recursiveDestroyContainer(child.second);
- }
- delete container;
-}
-
-void PJ_container_free_all ()
-{
- container_t root = PJ_container_get_root();
- if (root == nullptr){
- THROWF (tracing_error, 0, "trying to free all containers, but root is nullptr");
- }
- recursiveDestroyContainer (root);
- rootContainer = nullptr;
-
- //checks
- if (not allContainers.empty()) {
- THROWF(tracing_error, 0, "some containers still present even after destroying all of them");
- }
-}
static Value* get(const char* name, Type* father);
};
-
//--------------------------------------------------
typedef enum {
INSTR_HOST,
Container* container;
Type* type;
double value;
-
public:
SubVariableEvent(double timestamp, Container* container, Type* type, double value);
void print() override;
XBT_PUBLIC(simgrid::instr::Container*) PJ_container_get_or_null(const char* name);
XBT_PUBLIC(container_t) PJ_container_get_root ();
XBT_PUBLIC(void) PJ_container_set_root (container_t root);
-XBT_PUBLIC(void) PJ_container_free_all (void);
XBT_PUBLIC(void) PJ_container_remove_from_parent (container_t container);
/* instr_paje_types.c */