#include <simgrid/modelchecker.h>
#include <simgrid/s4u/Engine.hpp>
-#define SIMIX_H_NO_DEPRECATED_WARNING // avoid deprecation warning on include (remove with XBT_ATTRIB_DEPRECATED_v333)
-#include <simgrid/simix.h>
-
#include "mc/mc.h"
#include "src/instr/instr_private.hpp"
#include "src/kernel/EngineImpl.hpp"
static simgrid::kernel::actor::ActorCode maestro_code;
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
xbt::signal<void()> Engine::on_platform_creation;
xbt::signal<void()> Engine::on_platform_created;
xbt::signal<void()> Engine::on_simulation_start;
{
/* two actors may have pushed the same mbox_create simcall at the same time */
kernel::activity::MailboxImpl* mbox = kernel::actor::simcall_answered([&name, this] {
- auto m = pimpl->mailboxes_.emplace(name, nullptr);
- if (m.second) {
- m.first->second = new kernel::activity::MailboxImpl(name);
- XBT_DEBUG("Creating a mailbox at %p with name %s", m.first->second, name.c_str());
+ auto [m, inserted] = pimpl->mailboxes_.try_emplace(name, nullptr);
+ if (inserted) {
+ m->second = new kernel::activity::MailboxImpl(name);
+ XBT_DEBUG("Creating a mailbox at %p with name %s", m->second, name.c_str());
}
- return m.first->second;
+ return m->second;
});
return mbox->get_iface();
}
std::vector<ActorPtr> Engine::get_all_actors() const
{
std::vector<ActorPtr> actor_list;
- for (auto const& kv : pimpl->get_actor_list()) {
- actor_list.push_back(kv.second->get_iface());
+ for (auto const& [_, actor] : pimpl->get_actor_list()) {
+ actor_list.push_back(actor->get_iface());
}
return actor_list;
}
std::vector<ActorPtr> Engine::get_filtered_actors(const std::function<bool(ActorPtr)>& filter) const
{
std::vector<ActorPtr> actor_list;
- for (auto const& kv : pimpl->get_actor_list()) {
- if (filter(kv.second->get_iface()))
- actor_list.push_back(kv.second->get_iface());
+ for (auto const& [_, actor] : pimpl->get_actor_list()) {
+ if (filter(actor->get_iface()))
+ actor_list.push_back(actor->get_iface());
}
return actor_list;
}
}
void Engine::run_until(double max_date) const
{
- static bool callback_called = false;
- if (not callback_called) {
+ if (static bool callback_called = false; not callback_called) {
on_simulation_start();
callback_called = true;
}
std::vector<kernel::routing::NetPoint*> Engine::get_all_netpoints() const
{
std::vector<kernel::routing::NetPoint*> res;
- for (auto const& kv : pimpl->netpoints_)
- res.push_back(kv.second);
+ for (auto const& [_, netpoint] : pimpl->netpoints_)
+ res.push_back(netpoint);
return res;
}
return this;
}
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
/* **************************** Public C interface *************************** */
void simgrid_init(int* argc, char** argv)
#endif
maestro_code = std::bind(code, data);
}
-void SIMIX_set_maestro(void (*code)(void*), void* data) // XBT_ATTRIB_DEPRECATED_v333
-{
- simgrid_set_maestro(code, data);
-}