-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_init.cpp
More file actions
38 lines (31 loc) · 1.12 KB
/
app_init.cpp
File metadata and controls
38 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*********************************************************************
* @file app_init.cpp
* @brief Shared application initialization for all run_seastack modes.
*********************************************************************/
#include "app_init.h"
#include <seastack/adapters/chrono/helper.h>
#include <seastack/infra/logging.h>
#include <atomic>
#include <cstdlib>
#include <string>
namespace {
std::atomic<bool> g_chrono_env_initialized{false};
}
void seastack::app::InitChronoEnvironment() {
if (g_chrono_env_initialized.exchange(true)) {
return;
}
seastack::chrono::SetInitialEnvironment("");
// Export the resolved Chrono data path so that child processes (--run-cell
// subprocesses) inherit it without repeating the probe logic.
std::string chrono_path = seastack::chrono::GetChronoDataDir();
if (!chrono_path.empty()) {
#ifdef _WIN32
_putenv_s("CHRONO_DATA_DIR", chrono_path.c_str());
#else
setenv("CHRONO_DATA_DIR", chrono_path.c_str(), 1);
#endif
seastack::infra::debug::LogDebug(
std::string("Exported CHRONO_DATA_DIR=") + chrono_path);
}
}