1 /* Copyright (c) 2009 The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "surf_private.h"
8 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
10 const char *surf_action_state_names[6] = {
12 "SURF_ACTION_RUNNING",
15 "SURF_ACTION_TO_FREE",
16 "SURF_ACTION_NOT_IN_THE_SYSTEM"
19 e_surf_action_state_t surf_action_state_get(surf_action_t action)
21 surf_action_state_t action_state = &(action->model_type->states);
23 if (action->state_set == action_state->ready_action_set)
24 return SURF_ACTION_READY;
25 if (action->state_set == action_state->running_action_set)
26 return SURF_ACTION_RUNNING;
27 if (action->state_set == action_state->failed_action_set)
28 return SURF_ACTION_FAILED;
29 if (action->state_set == action_state->done_action_set)
30 return SURF_ACTION_DONE;
31 return SURF_ACTION_NOT_IN_THE_SYSTEM;
34 double surf_action_get_start_time(surf_action_t action)
39 double surf_action_get_finish_time(surf_action_t action)
41 return action->finish;
44 void surf_action_free(surf_action_t * action)
46 (*action)->model_type->action_cancel(*action);
51 void surf_action_state_set(surf_action_t action,
52 e_surf_action_state_t state)
54 surf_action_state_t action_state = &(action->model_type->states);
55 XBT_IN2("(%p,%s)", action, surf_action_state_names[state]);
56 xbt_swag_remove(action, action->state_set);
58 if (state == SURF_ACTION_READY)
59 action->state_set = action_state->ready_action_set;
60 else if (state == SURF_ACTION_RUNNING)
61 action->state_set = action_state->running_action_set;
62 else if (state == SURF_ACTION_FAILED)
63 action->state_set = action_state->failed_action_set;
64 else if (state == SURF_ACTION_DONE)
65 action->state_set = action_state->done_action_set;
67 action->state_set = NULL;
69 if (action->state_set)
70 xbt_swag_insert(action, action->state_set);
74 void surf_action_data_set(surf_action_t action, void *data)
79 void surf_action_ref(surf_action_t action)