/******************************** Deployment **********************************/
SG_BEGIN_DECL
-XBT_PUBLIC void SIMIX_function_register_default(xbt_main_func_t code);
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_register_default() or Engine::register_default()") XBT_PUBLIC
+ void SIMIX_function_register_default(xbt_main_func_t code);
+XBT_ATTRIB_DEPRECATED_v329("This function will be removed in 3.29") XBT_PUBLIC void SIMIX_init_application();
-XBT_PUBLIC void SIMIX_init_application();
XBT_PUBLIC void SIMIX_process_set_function(const char* process_host, const char* process_function,
xbt_dynar_t arguments, double process_start_time, double process_kill_time);
SG_END_DECL
#ifdef __cplusplus
-XBT_PUBLIC void SIMIX_function_register(const std::string& name, void (*code)(std::vector<std::string>));
-XBT_PUBLIC void SIMIX_function_register(const std::string& name, xbt_main_func_t code);
-XBT_PUBLIC void SIMIX_launch_application(const std::string& file);
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_register_function() or Engine::register_function()") XBT_PUBLIC
+ void SIMIX_function_register(const std::string& name, void (*code)(std::vector<std::string>));
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_register_function() or Engine::register_function()") XBT_PUBLIC
+ void SIMIX_function_register(const std::string& name, xbt_main_func_t code);
+XBT_ATTRIB_DEPRECATED_v329("Please use simgrid_load_deployment() or Engine::load_deployment()") XBT_PUBLIC
+ void SIMIX_launch_application(const std::string& file);
#endif
/********************************* Process ************************************/
{
const char *deploymentFile = env->GetStringUTFChars(jdeploymentFile, 0);
- SIMIX_function_register_default(java_main);
+ simgrid_register_default(java_main);
MSG_launch_application(deploymentFile);
}
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/EngineImpl.hpp"
+#include "simgrid/Exception.hpp"
#include "simgrid/kernel/routing/NetPoint.hpp"
#include "simgrid/kernel/routing/NetZoneImpl.hpp"
#include "simgrid/s4u/Host.hpp"
#include "src/kernel/resource/DiskImpl.hpp"
+#include "src/simix/smx_private.hpp"
#include "src/surf/StorageImpl.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/xml/platf_private.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
+
+extern int surf_parse_lineno;
namespace simgrid {
namespace kernel {
if (kv.second)
kv.second->get_impl()->destroy();
}
+
+void EngineImpl::load_deployment(const std::string& file)
+{
+ sg_platf_exit();
+ sg_platf_init();
+
+ surf_parse_open(file);
+ try {
+ int parse_status = surf_parse();
+ surf_parse_close();
+ xbt_assert(not parse_status, "Parse error at %s:%d", file.c_str(), surf_parse_lineno);
+ } catch (const Exception&) {
+ xbt_die(
+ "Unrecoverable error at %s:%d. The full exception stack follows, in case it helps you to diagnose the problem.",
+ file.c_str(), surf_parse_lineno);
+ throw;
+ }
+}
+void EngineImpl::register_function(const std::string& name, xbt_main_func_t code)
+{
+ simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
+ return simgrid::xbt::wrap_main(code, std::move(args));
+ };
+}
+
+void EngineImpl::register_function(const std::string& name, void (*code)(std::vector<std::string>))
+{
+ simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
+ return std::bind(std::move(code), std::move(args));
+ };
}
+
+void EngineImpl::register_default(xbt_main_func_t code)
+{
+ simix_global->default_function = [code](std::vector<std::string> args) {
+ return simgrid::xbt::wrap_main(code, std::move(args));
+ };
}
+
+} // namespace kernel
+} // namespace simgrid
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <simgrid/s4u/NetZone.hpp>
-
#include <map>
+#include <simgrid/s4u/NetZone.hpp>
+#include <simgrid/simix.hpp>
#include <string>
#include <unordered_map>
EngineImpl(const EngineImpl&) = delete;
EngineImpl& operator=(const EngineImpl&) = delete;
virtual ~EngineImpl();
+
+ void load_deployment(const std::string& file);
+ void register_function(const std::string& name, xbt_main_func_t code);
+ void register_function(const std::string& name, void (*code)(std::vector<std::string>));
+ void register_default(xbt_main_func_t code);
+
routing::NetZoneImpl* netzone_root_ = nullptr;
};
/** Registers the main function of an actor that will be launched from the deployment file */
void Engine::register_function(const std::string& name, int (*code)(int, char**))
{
- SIMIX_function_register(name, code);
+ pimpl->register_function(name, code);
}
+
/** 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>))
{
- SIMIX_function_register(name, code);
+ pimpl->register_function(name, code);
}
/** Registers a function as the default main function of actors
*
*/
void Engine::register_default(int (*code)(int, char**))
{
- SIMIX_function_register_default(code);
+ pimpl->register_default(code);
}
+
/** Load a deployment file and launch the actors that it contains
*
* \rst
*/
void Engine::load_deployment(const std::string& deploy)
{
- SIMIX_launch_application(deploy);
+ pimpl->load_deployment(deploy);
}
+
/** Returns the amount of hosts in the platform */
size_t Engine::get_host_count()
{
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "simgrid/Exception.hpp"
#include "simgrid/s4u/Host.hpp"
#include "smx_private.hpp"
#include "src/surf/xml/platf_private.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
#include <simgrid/engine.h>
+#include <simgrid/s4u/Engine.hpp>
#include <string>
#include <vector>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_deployment, simix, "Logging specific to SIMIX (deployment)");
-extern int surf_parse_lineno;
-
-void SIMIX_init_application()
+void SIMIX_init_application() // XBT_DEPRECATED_v329
{
sg_platf_exit();
sg_platf_init();
}
-/**
- * @brief An application deployer.
- *
- * Creates the process described in @a file.
- * @param file a filename of a xml description of the application. This file
- * follows this DTD :
- *
- * @include surfxml.dtd
- *
- * Here is a small example of such a platform
- *
- * @include small_deployment.xml
- *
- */
-void SIMIX_launch_application(const std::string& file)
-{
- XBT_ATTRIB_UNUSED int parse_status;
- xbt_assert(simix_global, "SIMIX_global_init has to be called before SIMIX_launch_application.");
-
- SIMIX_init_application();
-
- surf_parse_open(file);
- try {
- parse_status = surf_parse();
- surf_parse_close();
- xbt_assert(not parse_status, "Parse error at %s:%d", file.c_str(), surf_parse_lineno);
- } catch (const simgrid::Exception&) {
- XBT_ERROR(
- "Unrecoverable error at %s:%d. The full exception stack follows, in case it helps you to diagnose the problem.",
- file.c_str(), surf_parse_lineno);
- throw;
- }
-}
-
-// Wrap a main() function into a ActorCodeFactory:
-static simgrid::simix::ActorCodeFactory toActorCodeFactory(xbt_main_func_t code)
+void SIMIX_launch_application(const std::string& file) // XBT_DEPRECATED_v329
{
- return [code](std::vector<std::string> args) { return simgrid::xbt::wrap_main(code, std::move(args)); };
+ simgrid_load_deployment(file.c_str());
}
-static simgrid::simix::ActorCodeFactory toActorCodeFactory(void (*code)(std::vector<std::string>))
+void SIMIX_function_register(const std::string& name, xbt_main_func_t code) // XBT_DEPRECATED_v329
{
- return [code](std::vector<std::string> args) { return std::bind(std::move(code), std::move(args)); };
+ simgrid::s4u::Engine::get_instance()->register_function(name, code);
}
-
-/**
- * @brief Registers a #xbt_main_func_t code in a global table.
- *
- * Registers a code function in a global table.
- * This table is then used by #SIMIX_launch_application.
- * @param name the reference name of the function.
- * @param code the function
- */
-void SIMIX_function_register(const std::string& name, xbt_main_func_t code)
+void SIMIX_function_register(const std::string& name, void (*code)(std::vector<std::string>)) // XBT_DEPRECATED_v329
{
- simix_global->registered_functions[name] = toActorCodeFactory(code);
+ simgrid::s4u::Engine::get_instance()->register_function(name, code);
}
-void SIMIX_function_register(const std::string& name, void (*code)(std::vector<std::string>))
-{
- simix_global->registered_functions[name] = toActorCodeFactory(code);
-}
-
-/**
- * @brief Registers a #xbt_main_func_t code as default value.
- *
- * Registers a code function as being the default value. This function will get used by SIMIX_launch_application() when
- * there is no registered function of the requested name in.
- * @param code the function
- */
-void SIMIX_function_register_default(xbt_main_func_t code)
+void SIMIX_function_register_default(xbt_main_func_t code) // XBT_DEPRECATED_v329
{
- xbt_assert(simix_global, "SIMIX_global_init has to be called before SIMIX_function_register.");
- simix_global->default_function = toActorCodeFactory(code);
+ simgrid::s4u::Engine::get_instance()->register_default(code);
}
/**