Skip to content

Commit

Permalink
STYLE: MersenneTwisterGlobals replace std::recursive_mutex w/ std::mutex
Browse files Browse the repository at this point in the history
Replaced `std::recursive_mutex` with the more lightweight `std::mutex` as type
of `MersenneTwisterGlobals::m_StaticInstanceLock`. This mutex is only used
`MersenneTwisterRandomVariateGenerator::GetInstance()`. This member function
does not call itself, so the mutex does not need to be "recursive".
  • Loading branch information
N-Dekker authored and dzenanz committed Nov 21, 2023
1 parent fb8a573 commit dad0d82
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct MersenneTwisterGlobals
~MersenneTwisterGlobals() = default;

MersenneTwisterRandomVariateGenerator::Pointer m_StaticInstance{};
std::recursive_mutex m_StaticInstanceLock{};
std::mutex m_StaticInstanceLock{};
std::atomic<MersenneTwisterRandomVariateGenerator::IntegerType> m_StaticDiffer{};
};

Expand Down Expand Up @@ -72,7 +72,7 @@ MersenneTwisterRandomVariateGenerator::Pointer
MersenneTwisterRandomVariateGenerator::GetInstance()
{
itkInitGlobalsMacro(PimplGlobals);
const std::lock_guard<std::recursive_mutex> lockGuard(m_PimplGlobals->m_StaticInstanceLock);
const std::lock_guard<std::mutex> lockGuard(m_PimplGlobals->m_StaticInstanceLock);

if (!m_PimplGlobals->m_StaticInstance)
{
Expand Down

0 comments on commit dad0d82

Please sign in to comment.