// The communication initialization is done ASAP, as we need to get some init parameters from the MC for different
// layers. But instance_ needs to be created, as we send the address of some of its fields to the MC that wants to
// read them directly.
- simgrid::mc::AppSide::initialize();
+ simgrid::mc::AppSide::get(); // To ensure that it's initialized
#endif
if (static bool inited = false; not inited) {
std::unique_ptr<AppSide> AppSide::instance_;
-AppSide* AppSide::initialize()
+AppSide* AppSide::get()
{
- if (not std::getenv(MC_ENV_SOCKET_FD)) // We are not in MC mode: don't initialize the MC world
- return nullptr;
-
- // Do not break if we are called multiple times:
+ // Only initialize the MC world once
if (instance_)
return instance_.get();
+ if (not std::getenv(MC_ENV_SOCKET_FD)) // We are not in MC mode: don't initialize the MC world
+ return nullptr;
+
simgrid::mc::model_checking_mode = ModelCheckingMode::APP_SIDE;
setvbuf(stdout, nullptr, _IOLBF, 0);
void declare_stack(void* stack, size_t size, ucontext_t* context) const;
#endif
- // Singleton :/
// TODO, remove the singleton antipattern.
- static AppSide* initialize();
- static AppSide* get() { return instance_.get(); }
+ static AppSide* get();
};
} // namespace simgrid::mc