XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_timer, surf,
"Logging specific to SURF (timer)");
-surf_timer_model_t surf_timer_model = NULL;
+surf_model_t surf_timer_model = NULL;
static tmgr_trace_t empty_trace = NULL;
static xbt_swag_t command_pending = NULL;
static xbt_swag_t command_to_run = NULL;
static xbt_heap_t timer_heap = NULL;
-static void timer_free(void *timer)
-{
- free(timer);
-}
-
static command_t command_new(void *fun, void *args)
{
command_t command = xbt_new0(s_command_t, 1);
- command->model = (surf_model_t) surf_timer_model;
+ command->generic_resource.model = surf_timer_model;
command->function = fun;
command->args = args;
xbt_swag_insert(command, command_pending);
static void command_free(command_t command)
{
- free(command);
-
if (xbt_swag_belongs(command, command_to_run)) {
xbt_swag_remove(command, command_to_run);
} else if (xbt_swag_belongs(command, command_pending)) {
xbt_swag_remove(command, command_pending);
}
+ surf_resource_free((surf_resource_t)command);
return;
}
{
}
-static void *name_service(const char *name)
-{
- DIE_IMPOSSIBLE;
- return NULL;
-}
-
-static const char *get_resource_name(void *resource_id)
-{
- DIE_IMPOSSIBLE;
- return "";
-}
-
static int resource_used(void *resource_id)
{
return 1;
}
-static int action_free(surf_action_t action)
-{
- DIE_IMPOSSIBLE;
- return 1;
-}
-
-static void action_cancel(surf_action_t action)
-{
- DIE_IMPOSSIBLE;
- return;
-}
-
-static void action_recycle(surf_action_t action)
-{
- DIE_IMPOSSIBLE;
- return;
-}
-
static void action_change_state(surf_action_t action,
e_surf_action_state_t state)
{
xbt_swag_free(command_pending);
xbt_swag_free(command_to_run);
- xbt_swag_free(surf_timer_model->common_public->states.ready_action_set);
- xbt_swag_free(surf_timer_model->common_public->states.running_action_set);
- xbt_swag_free(surf_timer_model->common_public->states.failed_action_set);
- xbt_swag_free(surf_timer_model->common_public->states.done_action_set);
- free(surf_timer_model->common_public);
- free(surf_timer_model->common_private);
- free(surf_timer_model->extension_public);
-
- free(surf_timer_model);
+ surf_model_exit(surf_timer_model);
surf_timer_model = NULL;
}
static void surf_timer_model_init_internal(void)
{
- s_surf_action_t action;
-
- surf_timer_model = xbt_new0(s_surf_timer_model_t, 1);
-
- surf_timer_model->common_private = xbt_new0(s_surf_model_private_t, 1);
- surf_timer_model->common_public = xbt_new0(s_surf_model_public_t, 1);
-
- surf_timer_model->extension_public =
- xbt_new0(s_surf_timer_model_extension_public_t, 1);
-
- surf_timer_model->common_public->states.ready_action_set =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_timer_model->common_public->states.running_action_set =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_timer_model->common_public->states.failed_action_set =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_timer_model->common_public->states.done_action_set =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
-
- surf_timer_model->common_public->name_service = name_service;
- surf_timer_model->common_public->get_resource_name = get_resource_name;
- surf_timer_model->common_public->action_get_state = surf_action_get_state;
- surf_timer_model->common_public->action_free = action_free;
- surf_timer_model->common_public->action_cancel = action_cancel;
- surf_timer_model->common_public->action_recycle = action_recycle;
- surf_timer_model->common_public->action_change_state = action_change_state;
- surf_timer_model->common_public->action_set_data = surf_action_set_data;
- surf_timer_model->common_public->name = "TIMER";
-
- surf_timer_model->common_private->resource_used = resource_used;
- surf_timer_model->common_private->share_resources = share_resources;
- surf_timer_model->common_private->update_actions_state =
+ surf_timer_model = surf_model_init();
+
+ surf_timer_model->action_get_state = surf_action_get_state;
+ surf_timer_model->action_change_state = action_change_state;
+ surf_timer_model->action_set_data = surf_action_set_data;
+ surf_timer_model->name = "TIMER";
+
+ surf_timer_model->model_private->resource_used = resource_used;
+ surf_timer_model->model_private->share_resources = share_resources;
+ surf_timer_model->model_private->update_actions_state =
update_actions_state;
- surf_timer_model->common_private->update_resource_state =
+ surf_timer_model->model_private->update_resource_state =
update_resource_state;
- surf_timer_model->common_private->finalize = finalize;
+ surf_timer_model->model_private->finalize = finalize;
- surf_timer_model->common_public->suspend = action_suspend;
- surf_timer_model->common_public->resume = action_resume;
- surf_timer_model->common_public->is_suspended = action_is_suspended;
+ surf_timer_model->suspend = action_suspend;
+ surf_timer_model->resume = action_resume;
+ surf_timer_model->is_suspended = action_is_suspended;
- surf_timer_model->extension_public->set = set;
- surf_timer_model->extension_public->get = get;
+ surf_timer_model->extension.timer.set = set;
+ surf_timer_model->extension.timer.get = get;
{
s_command_t var;