diff --git a/src/daemon/xmrig_manager.cpp b/src/daemon/xmrig_manager.cpp index 776896b..03ab12d 100644 --- a/src/daemon/xmrig_manager.cpp +++ b/src/daemon/xmrig_manager.cpp @@ -173,9 +173,10 @@ bool XmrigManager::generateConfig(const Config& cfg, const std::string& outPath) int hw = (int)std::thread::hardware_concurrency(); if (hw < 1) hw = 1; - // Use explicit thread count (not just a hint) - threads_ = (cfg.threads > 0) ? cfg.threads : std::max(1, hw / 2); - if (threads_ > hw) threads_ = hw; + // Use explicit thread count (not just a hint). One store: the UI thread reads it (getRequestedThreads). + int t = (cfg.threads > 0) ? cfg.threads : std::max(1, hw / 2); + if (t > hw) t = hw; + threads_ = t; json j; j["autosave"] = false; @@ -324,7 +325,7 @@ bool XmrigManager::start(const Config& cfg) { return false; } DEBUG_LOGF("[INFO] XmrigManager: config written to %s (API port %d, threads %d)\n", - cfgPath.c_str(), api_port_, threads_); + cfgPath.c_str(), api_port_, threads_.load()); // Spawn process if (!startProcess(binary, cfgPath, threads_)) { diff --git a/src/daemon/xmrig_manager.h b/src/daemon/xmrig_manager.h index 54d1834..3a7bf8d 100644 --- a/src/daemon/xmrig_manager.h +++ b/src/daemon/xmrig_manager.h @@ -173,7 +173,7 @@ private: // xmrig HTTP API credentials (random per session) int api_port_ = 0; std::string api_token_; - int threads_ = 0; // Thread count for mining + std::atomic threads_{0}; // Thread count for mining (written on the mining-control thread, read by the UI) std::string pool_host_; // Pool hostname for stats API PoolStats stats_; mutable std::mutex stats_mutex_;