diff --git a/src/rime.cpp b/src/rime.cpp index e96ace8..c87ec9f 100644 --- a/src/rime.cpp +++ b/src/rime.cpp @@ -1,8 +1,11 @@ #include +#include #include "rime.h" namespace fs = std::filesystem; +static std::atomic rime_initialized = false; + Rime::Rime(fs::path source_dir, const std::string& schema_id, std::optional cache_dir, @@ -32,8 +35,11 @@ Rime::Rime(fs::path source_dir, traits.user_data_dir = user_data_dir.c_str(); traits.log_dir = log_dir.c_str(); traits.staging_dir = staging_dir.c_str(); - api->setup(&traits); - api->initialize(NULL); + if (!rime_initialized.load()) { + api->setup(&traits); + api->initialize(NULL); + rime_initialized.store(true); + } if (deploy_now && api->start_maintenance(/* full_check */ true)) api->join_maintenance_thread(); }