Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

fix: make get hardware info function thread-safe #1956

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions engine/services/hardware_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bool TryConnectToServer(const std::string& host, int port) {

HardwareInfo HardwareService::GetHardwareInfo() {
// append active state
std::lock_guard<std::mutex> l(mtx_);
auto gpus = cortex::hw::GetGPUInfo();
auto res = db_service_->LoadHardwareList();
if (res.has_value()) {
Expand Down
2 changes: 2 additions & 0 deletions engine/services/hardware_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdint.h>
#include <string>
#include <vector>
#include <mutex>

#include "common/hardware_config.h"
#include "database_service.h"
Expand Down Expand Up @@ -39,4 +40,5 @@ class HardwareService {
private:
std::shared_ptr<DatabaseService> db_service_ = nullptr;
std::optional<cortex::hw::ActivateHardwareConfig> ahc_;
std::mutex mtx_;
};
Loading