Skip to content

Commit b51082c

Browse files
committed
OrcLib: SystemIdentity: use CpuInfo for better compatibility
1 parent 28f010c commit b51082c

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/OrcLib/SystemIdentity.cpp

+11-18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "ProfileList.h"
1616
#include "SystemDetails.h"
1717

18+
#include "CpuInfo.h"
19+
1820
HRESULT Orc::SystemIdentity::Write(const std::shared_ptr<StructuredOutput::IOutput>& writer, IdentityArea areas)
1921
{
2022
if (areas & IdentityArea::Process)
@@ -484,26 +486,17 @@ HRESULT Orc::SystemIdentity::CPU(const std::shared_ptr<StructuredOutput::IOutput
484486
BOOST_SCOPE_EXIT(&writer, &elt) { writer->EndCollection(elt); }
485487
BOOST_SCOPE_EXIT_END;
486488

487-
auto result = SystemDetails::GetCPUInfo();
488-
if (!result)
489-
{
490-
assert(result.error().category() == std::system_category());
491-
return result.error().value();
492-
}
489+
writer->BeginElement(nullptr);
490+
BOOST_SCOPE_EXIT(&writer) { writer->EndElement(nullptr); }
491+
BOOST_SCOPE_EXIT_END;
493492

494-
const auto& cpus = result.value();
495-
for (const auto& cpu : cpus)
496-
{
497-
writer->BeginElement(nullptr);
498-
BOOST_SCOPE_EXIT(&writer) { writer->EndElement(nullptr); }
499-
BOOST_SCOPE_EXIT_END;
493+
CpuInfo cpuInfo;
494+
writer->WriteNamed(L"manufacturer", cpuInfo.Manufacturer());
495+
writer->WriteNamed(L"name", cpuInfo.Name());
496+
writer->WriteNamed(L"physical_processors", cpuInfo.PhysicalCores());
497+
writer->WriteNamed(L"logical_processors", cpuInfo.LogicalCores());
498+
writer->WriteNamed(L"hyperthreading", cpuInfo.IsHyperThreadingEnabled());
500499

501-
writer->WriteNamed(L"name", cpu.Name.c_str());
502-
writer->WriteNamed(L"description", cpu.Description.c_str());
503-
writer->WriteNamed(L"cores", (ULONG32)cpu.Cores);
504-
writer->WriteNamed(L"enabled_cores", (ULONG32)cpu.EnabledCores);
505-
writer->WriteNamed(L"logical_processors", (ULONG32)cpu.LogicalProcessors);
506-
}
507500
return S_OK;
508501
}
509502

0 commit comments

Comments
 (0)