Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move surf_action related function to a specific file
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 1 Jul 2009 09:52:38 +0000 (09:52 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 1 Jul 2009 09:52:38 +0000 (09:52 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6420 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/Makefile.am
src/surf/surf.c
src/surf/surf_action.c [new file with mode: 0644]

index 73db507..66155e6 100644 (file)
@@ -170,6 +170,7 @@ XBT_SG_SRC = \
 SURF_SRC= \
   surf/surf_model.c                                                          \
   surf/surf_resource.c                                                       \
+  surf/surf_action.c                                                         \
   surf/surf_config.c                                                         \
   surf/maxmin.c                                                              \
   surf/fair_bottleneck.c                                                     \
index baf337f..0ac05fb 100644 (file)
@@ -112,14 +112,6 @@ xbt_dynar_t model_list = NULL;
 tmgr_history_t history = NULL;
 lmm_system_t maxmin_system = NULL;
 xbt_dynar_t surf_path = NULL;
-const char *surf_action_state_names[6] = {
-  "SURF_ACTION_READY",
-  "SURF_ACTION_RUNNING",
-  "SURF_ACTION_FAILED",
-  "SURF_ACTION_DONE",
-  "SURF_ACTION_TO_FREE",
-  "SURF_ACTION_NOT_IN_THE_SYSTEM"
-};
 
 /* Don't forget to update the option description in smx_config when you change this */
 s_surf_model_description_t surf_network_model_description[] = {
@@ -236,65 +228,6 @@ double generic_maxmin_share_resources(xbt_swag_t running_actions,
   return min;
 }
 
-e_surf_action_state_t surf_action_get_state(surf_action_t action)
-{
-  surf_action_state_t action_state = &(action->model_type->states);
-
-  if (action->state_set == action_state->ready_action_set)
-    return SURF_ACTION_READY;
-  if (action->state_set == action_state->running_action_set)
-    return SURF_ACTION_RUNNING;
-  if (action->state_set == action_state->failed_action_set)
-    return SURF_ACTION_FAILED;
-  if (action->state_set == action_state->done_action_set)
-    return SURF_ACTION_DONE;
-  return SURF_ACTION_NOT_IN_THE_SYSTEM;
-}
-
-double surf_action_get_start_time(surf_action_t action)
-{
-  return action->start;
-}
-
-double surf_action_get_finish_time(surf_action_t action)
-{
-  return action->finish;
-}
-
-void surf_action_free(surf_action_t * action)
-{
-  (*action)->model_type->action_cancel(*action);
-  free(*action);
-  *action = NULL;
-}
-
-void surf_action_change_state(surf_action_t action,
-                              e_surf_action_state_t state)
-{
-  surf_action_state_t action_state = &(action->model_type->states);
-  XBT_IN2("(%p,%s)", action, surf_action_state_names[state]);
-  xbt_swag_remove(action, action->state_set);
-
-  if (state == SURF_ACTION_READY)
-    action->state_set = action_state->ready_action_set;
-  else if (state == SURF_ACTION_RUNNING)
-    action->state_set = action_state->running_action_set;
-  else if (state == SURF_ACTION_FAILED)
-    action->state_set = action_state->failed_action_set;
-  else if (state == SURF_ACTION_DONE)
-    action->state_set = action_state->done_action_set;
-  else
-    action->state_set = NULL;
-
-  if (action->state_set)
-    xbt_swag_insert(action, action->state_set);
-  XBT_OUT;
-}
-
-void surf_action_set_data(surf_action_t action, void *data)
-{
-  action->data = data;
-}
 
 XBT_LOG_EXTERNAL_CATEGORY(surf_cpu);
 XBT_LOG_EXTERNAL_CATEGORY(surf_kernel);
diff --git a/src/surf/surf_action.c b/src/surf/surf_action.c
new file mode 100644 (file)
index 0000000..a086119
--- /dev/null
@@ -0,0 +1,77 @@
+/* Copyright (c) 2009 The SimGrid Team. All rights reserved.                */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "surf_private.h"
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
+
+const char *surf_action_state_names[6] = {
+  "SURF_ACTION_READY",
+  "SURF_ACTION_RUNNING",
+  "SURF_ACTION_FAILED",
+  "SURF_ACTION_DONE",
+  "SURF_ACTION_TO_FREE",
+  "SURF_ACTION_NOT_IN_THE_SYSTEM"
+};
+
+e_surf_action_state_t surf_action_get_state(surf_action_t action)
+{
+  surf_action_state_t action_state = &(action->model_type->states);
+
+  if (action->state_set == action_state->ready_action_set)
+    return SURF_ACTION_READY;
+  if (action->state_set == action_state->running_action_set)
+    return SURF_ACTION_RUNNING;
+  if (action->state_set == action_state->failed_action_set)
+    return SURF_ACTION_FAILED;
+  if (action->state_set == action_state->done_action_set)
+    return SURF_ACTION_DONE;
+  return SURF_ACTION_NOT_IN_THE_SYSTEM;
+}
+
+double surf_action_get_start_time(surf_action_t action)
+{
+  return action->start;
+}
+
+double surf_action_get_finish_time(surf_action_t action)
+{
+  return action->finish;
+}
+
+void surf_action_free(surf_action_t * action)
+{
+  (*action)->model_type->action_cancel(*action);
+  free(*action);
+  *action = NULL;
+}
+
+void surf_action_change_state(surf_action_t action,
+                              e_surf_action_state_t state)
+{
+  surf_action_state_t action_state = &(action->model_type->states);
+  XBT_IN2("(%p,%s)", action, surf_action_state_names[state]);
+  xbt_swag_remove(action, action->state_set);
+
+  if (state == SURF_ACTION_READY)
+    action->state_set = action_state->ready_action_set;
+  else if (state == SURF_ACTION_RUNNING)
+    action->state_set = action_state->running_action_set;
+  else if (state == SURF_ACTION_FAILED)
+    action->state_set = action_state->failed_action_set;
+  else if (state == SURF_ACTION_DONE)
+    action->state_set = action_state->done_action_set;
+  else
+    action->state_set = NULL;
+
+  if (action->state_set)
+    xbt_swag_insert(action, action->state_set);
+  XBT_OUT;
+}
+
+void surf_action_set_data(surf_action_t action, void *data)
+{
+  action->data = data;
+}