virtual double next_occuring_event_lazy(double now);
virtual double next_occuring_event_full(double now);
+private:
+ Action* extract_action(Action::StateSet* list);
+
+public:
+ Action* extract_done_action();
+ Action* extract_failed_action();
+
/**
* @brief Update action to the current time
*
/** @{ @ingroup SURF_c_bindings */
-/**
- * @brief Pop an action from the done actions set
- *
- * @param model The model from which the action is extracted
- * @return An action in done state
- */
-XBT_PUBLIC simgrid::kernel::resource::Action*
-surf_model_extract_done_action_set(simgrid::kernel::resource::Model* model);
-
-/**
- * @brief Pop an action from the failed actions set
- *
- * @param model The model from which the action is extracted
- * @return An action in failed state
- */
-XBT_PUBLIC simgrid::kernel::resource::Action*
-surf_model_extract_failed_action_set(simgrid::kernel::resource::Model* model);
-
/**
* @brief Get the size of the running action set of a model
*
xbt_die("Invalid cpu update mechanism!");
}
+/** Pops and returns the first action of that state set (or nullptr if none exist) */
+Action* Model::extract_action(Action::StateSet* list)
+{
+ if (list->empty())
+ return nullptr;
+ simgrid::kernel::resource::Action* res = &list->front();
+ list->pop_front();
+ return res;
+}
+
+/** Pops and returns the first finished action (or nullptr if none exist) */
+Action* Model::extract_done_action()
+{
+ return extract_action(get_finished_action_set());
+}
+
+/** Pops and returns the failed finished action (or nullptr if none exist) */
+Action* Model::extract_failed_action()
+{
+ return extract_action(get_failed_action_set());
+}
+
void Model::update_actions_state_lazy(double /*now*/, double /*delta*/)
{
THROW_UNIMPLEMENTED;
/* let's see which tasks are done */
for (auto const& model : *all_existing_models) {
- simgrid::kernel::resource::Action* action = surf_model_extract_done_action_set(model);
+ simgrid::kernel::resource::Action* action = model->extract_done_action();
while (action != nullptr && action->get_data() != nullptr) {
SD_task_t task = static_cast<SD_task_t>(action->get_data());
XBT_VERB("Task '%s' done", SD_task_get_name(task));
SD_task_run(output);
}
task->outputs->clear();
- action = surf_model_extract_done_action_set(model);
+ action = model->extract_done_action();
}
/* let's see which tasks have just failed */
- action = surf_model_extract_failed_action_set(model);
+ action = model->extract_failed_action();
while (action != nullptr) {
SD_task_t task = static_cast<SD_task_t>(action->get_data());
XBT_VERB("Task '%s' failed", SD_task_get_name(task));
SD_task_set_state(task, SD_FAILED);
sd_global->return_set->insert(task);
- action = surf_model_extract_failed_action_set(model);
+ action = model->extract_failed_action();
}
}
}
simgrid::kernel::resource::Action* action;
XBT_DEBUG("Handling the processes whose action failed (if any)");
- while ((action = surf_model_extract_failed_action_set(model))) {
+ while ((action = model->extract_failed_action())) {
XBT_DEBUG(" Handling Action %p",action);
SIMIX_simcall_exit(static_cast<simgrid::kernel::activity::ActivityImpl*>(action->get_data()));
}
XBT_DEBUG("Handling the processes whose action terminated normally (if any)");
- while ((action = surf_model_extract_done_action_set(model))) {
+ while ((action = model->extract_done_action())) {
XBT_DEBUG(" Handling Action %p",action);
if (action->get_data() == nullptr)
XBT_DEBUG("probably vcpu's action %p, skip", action);
/*********
* MODEL *
*********/
-static simgrid::kernel::resource::Action* ActionListExtract(simgrid::kernel::resource::Action::StateSet* list)
-{
- if (list->empty())
- return nullptr;
- simgrid::kernel::resource::Action* res = &list->front();
- list->pop_front();
- return res;
-}
-
-simgrid::kernel::resource::Action* surf_model_extract_done_action_set(simgrid::kernel::resource::Model* model)
-{
- return ActionListExtract(model->get_finished_action_set());
-}
-
-simgrid::kernel::resource::Action* surf_model_extract_failed_action_set(simgrid::kernel::resource::Model* model)
-{
- return ActionListExtract(model->get_failed_action_set());
-}
-
int surf_model_running_action_set_size(simgrid::kernel::resource::Model* model)
{
return model->get_started_action_set()->size();
running = 1;
}
- action = surf_model_extract_failed_action_set(model);
+ action = model->extract_failed_action();
while (action != nullptr) {
XBT_INFO(" * Done Action");
XBT_DEBUG("\t * Failed Action: %p", action);
action->unref();
- action = surf_model_extract_failed_action_set(model);
+ action = model->extract_failed_action();
}
- action = surf_model_extract_done_action_set(model);
+ action = model->extract_done_action();
while (action != nullptr){
XBT_INFO(" * Done Action");
XBT_DEBUG("\t * Done Action: %p", action);
action->unref();
- action = surf_model_extract_done_action_set(model);
+ action = model->extract_done_action();
}
}
} while (running && surf_solve(-1.0) >= 0.0);