#include "simdag_private.hpp"
#include "simgrid/simdag.h"
#include "src/internal_config.h"
-#include "xbt/file.h"
+#include "xbt/file.hpp"
#include <cstring>
#include <unordered_map>
if ((performer != -1 && order != -1) && performer < static_cast<int>(sg_host_count())) {
/* required parameters are given and less performers than hosts are required */
XBT_DEBUG ("Task '%s' is scheduled on workstation '%d' in position '%d'", task->name, performer, order);
- try {
- computer = computers.at(char_performer);
- } catch (std::out_of_range& unfound) {
+ auto comp = computers.find(char_performer);
+ if (comp != computers.end()) {
+ computer = comp->second;
+ } else {
computer = new std::vector<SD_task_t>;
computers.insert({char_performer, computer});
}
if(schedule){
if (schedule_success) {
- const sg_host_t *workstations = sg_host_list ();
- for (auto elm : computers) {
+ sg_host_t* workstations = sg_host_list();
+ for (auto const& elm : computers) {
SD_task_t previous_task = nullptr;
- for (auto task : *elm.second) {
+ for (auto const& task : *elm.second) {
/* add dependency between the previous and the task to avoid parallel execution */
if(task){
if (previous_task && not SD_task_dependency_exists(previous_task, task))
}
delete elm.second;
}
+ xbt_free(workstations);
} else {
XBT_WARN("The scheduling is ignored");
- for (auto elm : computers)
+ for (auto const& elm : computers)
delete elm.second;
xbt_dynar_free(&result);
result = nullptr;
}
if (result && not acyclic_graph_detail(result)) {
- char* base = xbt_basename(filename);
- XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.", base);
- free(base);
+ std::string base = simgrid::xbt::Path(filename).getBasename();
+ XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.", base.c_str());
xbt_dynar_free(&result);
result = nullptr;
}