surf_model_t model;
char *name;
xbt_dict_t properties;
+ void_f_pvoid_t free_f;
} s_surf_resource_t, *surf_resource_t;
/**
static XBT_INLINE
surf_resource_t surf_resource_new(size_t childsize,
surf_model_t model, const char *name,
- xbt_dict_t props)
+ xbt_dict_t props, void_f_pvoid_t free_f)
{
surf_resource_t res = xbt_malloc0(childsize);
res->model = model;
res->name = xbt_strdup(name);
res->properties = props;
+ res->free_f=free_f;
return res;
}
static XBT_INLINE void surf_resource_free(void *r)
{
surf_resource_t resource = r;
+ if(resource->free_f)
+ resource->free_f(r);
free(resource->name);
xbt_dict_free(&resource->properties);
free(resource);
surf_resource_lmm_t res =
(surf_resource_lmm_t) surf_resource_new(childsize, model, name,
- props);
+ props, NULL);
res->constraint = lmm_constraint_new(system, res, constraint_value);
res->state_current = state_init;
static xbt_swag_t
cpu_running_action_set_that_does_not_need_being_checked = NULL;
+/* Additionnal callback function to cleanup some data, called from surf_resource_free */
+
+static void cpu_cas1_cleanup(void* r){
+ cpu_Cas01_t cpu = (cpu_Cas01_t)r;
+ unsigned int iter;
+ xbt_dynar_t power_tuple = NULL;
+ xbt_dynar_foreach(cpu->energy->power_range_watts_list, iter, power_tuple)
+ xbt_dynar_free(&power_tuple);
+ xbt_dynar_free(&cpu->energy->power_range_watts_list);
+ xbt_dynar_free(&cpu->power_peak_list);
+ xbt_free(cpu->energy);
+ return;
+}
/* This function is registered as a callback to sg_platf_new_host() and never called directly */
static void *cpu_create_resource(const char *name, xbt_dynar_t power_peak,
name);
cpu = (cpu_Cas01_t) surf_resource_new(sizeof(s_cpu_Cas01_t),
surf_cpu_model, name,
- cpu_properties);
+ cpu_properties, &cpu_cas1_cleanup);
cpu->power_peak = xbt_dynar_get_as(power_peak, pstate, double);
cpu->power_peak_list = power_peak;
cpu->pstate = pstate;
name);
xbt_assert(core==1,"Multi-core not handled with this model yet");
cpu = (cpu_ti_t) surf_resource_new(sizeof(s_cpu_ti_t),
- surf_cpu_model, name,cpu_properties);
+ surf_cpu_model, name,cpu_properties, NULL);
cpu->action_set =
xbt_swag_new(xbt_swag_offset(ti_action, cpu_list_hookup));
"Storage '%s' declared several times in the platform file",
id);
storage = (storage_t) surf_resource_new(sizeof(s_storage_t),
- surf_storage_model, id, properties);
+ surf_storage_model, id, properties, NULL);
storage->generic_resource.name = xbt_strdup(id);
storage->state_current = SURF_RESOURCE_ON;
name);
cpu = (cpu_L07_t) surf_resource_new(sizeof(s_cpu_L07_t),
- surf_workstation_model, name,cpu_properties);
+ surf_workstation_model, name,cpu_properties, NULL);
cpu->type = SURF_WORKSTATION_RESOURCE_CPU;
cpu->info = xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL);