#include <simgrid/s4u/Mailbox.hpp>
#include <simgrid/version.h>
+#include <algorithm>
#include <memory>
#include <string>
#include <vector>
namespace {
-static std::string get_simgrid_version()
+std::string get_simgrid_version()
{
int major;
int minor;
/* Class Engine */
py::class_<Engine>(m, "Engine", "Simulation Engine")
.def(py::init([](std::vector<std::string> args) {
- static char noarg[] = {'\0'};
auto argc = static_cast<int>(args.size());
- auto argv = std::make_unique<char*[]>(argc + 1);
- for (int i = 0; i != argc; ++i)
- argv[i] = args[i].empty() ? noarg : &args[i].front();
- argv[argc] = nullptr;
+ std::vector<char*> argv(args.size() + 1); // argv[argc] is nullptr
+ std::transform(begin(args), end(args), begin(argv), [](std::string& s) { return &s.front(); });
// Currently this can be dangling, we should wrap this somehow.
- return new simgrid::s4u::Engine(&argc, argv.get());
+ return new simgrid::s4u::Engine(&argc, argv.data());
}))
.def_static("get_clock", &Engine::get_clock,
"The simulation time, ie the amount of simulated seconds since the simulation start.")
.def("is_daemon", &Actor::is_daemon,
"Returns True if that actor is a daemon and will be terminated automatically when the last non-daemon actor "
"terminates.")
- .def("join", py::overload_cast<double>(&Actor::join), py::call_guard<GilScopedRelease>(),
+ .def("join", py::overload_cast<double>(&Actor::join, py::const_), py::call_guard<GilScopedRelease>(),
"Wait for the actor to finish (more info in the C++ documentation).", py::arg("timeout"))
.def("kill", &Actor::kill, py::call_guard<GilScopedRelease>(), "Kill that actor")
.def("kill_all", &Actor::kill_all, py::call_guard<GilScopedRelease>(), "Kill all actors but the caller.")