Skip to content

Commit

Permalink
fix: do not initialize rime multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
ksqsf committed Dec 15, 2024
1 parent 97499db commit cee70b6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/rime.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <iostream>
#include <atomic>
#include "rime.h"

namespace fs = std::filesystem;

static std::atomic<bool> rime_initialized = false;

Rime::Rime(fs::path source_dir,
const std::string& schema_id,
std::optional<fs::path> cache_dir,
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit cee70b6

Please sign in to comment.