Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
Description
CpuInfo singleton is created and initialized on first invocation of
CpuInfo::GetInstance(). All calls afterwards return reference to the
same instance. Current code uses std::mutex to make sure that CpuInfo
is created only once, but it introduces unnecessary overhead for later
calls. Concurrent threads getting the created instance should not block
each other.
Replace std::mutex with std::call_once to fix this issue.
References:
[1] https://en.cppreference.com/w/cpp/thread/call_once
[2] http://www.modernescpp.com/index.php/thread-safe-initialization-of-data
Attachments
Issue Links
- links to