#include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
#include <simgrid/Exception.hpp>
+#include <algorithm>
#include <string>
XBT_LOG_NEW_CATEGORY(s4u, "Log channels of the S4U (Simgrid for you) interface");
void Engine::register_function(const std::string& name, int (*code)(int, char**)) // deprecated
{
- pimpl->register_function(name, code);
+ register_function(name, [code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
}
void Engine::register_default(int (*code)(int, char**)) // deprecated
{
- pimpl->register_default(code);
+ register_default([code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
}
/** Registers the main function of an actor that will be launched from the deployment file */
void Engine::register_function(const std::string& name, void (*code)(int, char**))
{
- pimpl->register_function(name, code);
+ register_function(name, [code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
}
/** Registers the main function of an actor that will be launched from the deployment file */
void Engine::register_function(const std::string& name, void (*code)(std::vector<std::string>))
{
- pimpl->register_function(name, code);
+ register_function(name,
+ [code](std::vector<std::string> args) { return std::bind(std::move(code), std::move(args)); });
}
/** Registers a function as the default main function of actors
*
*/
void Engine::register_default(void (*code)(int, char**))
{
- pimpl->register_default(code);
+ register_default([code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
+}
+void Engine::register_default(const kernel::actor::ActorCodeFactory& code)
+{
+ simgrid::kernel::actor::simcall([this, &code]() { pimpl->register_default(code); });
+}
+
+void Engine::register_function(const std::string& name, const kernel::actor::ActorCodeFactory& code)
+{
+ simgrid::kernel::actor::simcall([this, name, &code]() { pimpl->register_function(name, code); });
}
/** Load a deployment file and launch the actors that it contains
std::vector<ActorPtr> Engine::get_all_actors()
{
std::vector<ActorPtr> actor_list;
- actor_list.push_back(simgrid::s4u::Actor::self());
for (auto const& kv : simix_global->process_list) {
actor_list.push_back(kv.second->iface());
}