Skip to content

Commit

Permalink
STYLE: Replace Registration/Metricsv4 "LockPtr" with "MutexPtr"
Browse files Browse the repository at this point in the history
Renamed the private `MattesMutualInformationImageToImageMetricv4` data member
`m_ParentJointPDFDerivativesLockPtr` to `m_ParentJointPDFDerivativesMutexPtr`,
as it is a mutex pointer.
  • Loading branch information
N-Dekker authored and dzenanz committed Sep 19, 2023
1 parent fa91fab commit 8149ba9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Expand Up @@ -279,9 +279,9 @@ class ITK_TEMPLATE_EXPORT MattesMutualInformationImageToImageMetricv4
*
* Thread safety note:
* A separate object is used locally per each thread. Only the members
* m_ParentJointPDFDerivativesLockPtr and m_ParentJointPDFDerivatives
* m_ParentJointPDFDerivativesMutexPtr and m_ParentJointPDFDerivatives
* are shared between threads and access to m_ParentJointPDFDerivatives
* is controlled with the m_ParentJointPDFDerivativesLockPtr mutex lock.
* is controlled with the m_ParentJointPDFDerivativesMutexPtr mutex lock.
* \ingroup ITKMetricsv4
*/
class DerivativeBufferManager
Expand All @@ -294,7 +294,7 @@ class ITK_TEMPLATE_EXPORT MattesMutualInformationImageToImageMetricv4
void
Initialize(size_t maxBufferLength,
const size_t cachedNumberOfLocalParameters,
std::mutex * parentDerivativeLockPtr,
std::mutex * parentDerivativeMutexPtr,
typename JointPDFDerivativesType::Pointer parentJointPDFDerivatives);

void
Expand Down Expand Up @@ -354,7 +354,7 @@ class ITK_TEMPLATE_EXPORT MattesMutualInformationImageToImageMetricv4
size_t m_CachedNumberOfLocalParameters;
size_t m_MaxBufferSize;
// Pointer handle to parent version
std::mutex * m_ParentJointPDFDerivativesLockPtr;
std::mutex * m_ParentJointPDFDerivativesMutexPtr;
// Smart pointer handle to parent version
typename JointPDFDerivativesType::Pointer m_ParentJointPDFDerivatives;
};
Expand Down
Expand Up @@ -555,7 +555,7 @@ MattesMutualInformationImageToImageMetricv4<TFixedImage,
TMetricTraits>::DerivativeBufferManager ::
Initialize(size_t maxBufferLength,
const size_t cachedNumberOfLocalParameters,
std::mutex * parentDerivativeLockPtr,
std::mutex * parentDerivativeMutexPtr,
typename JointPDFDerivativesType::Pointer parentJointPDFDerivatives)
{
m_CurrentFillSize = 0;
Expand All @@ -564,7 +564,7 @@ MattesMutualInformationImageToImageMetricv4<TFixedImage,
m_BufferOffsetContainer.resize(maxBufferLength, 0);
m_CachedNumberOfLocalParameters = cachedNumberOfLocalParameters;
m_MaxBufferSize = maxBufferLength;
m_ParentJointPDFDerivativesLockPtr = parentDerivativeLockPtr;
m_ParentJointPDFDerivativesMutexPtr = parentDerivativeMutexPtr;
m_ParentJointPDFDerivatives = parentJointPDFDerivatives;
// Allocate and initialize to zero (note the () at the end of the new
// operator)
Expand Down Expand Up @@ -614,7 +614,7 @@ MattesMutualInformationImageToImageMetricv4<TFixedImage,
if (m_CurrentFillSize == m_MaxBufferSize)
{
// Attempt to acquire the lock once
std::unique_lock<std::mutex> FirstTryLockHolder(*this->m_ParentJointPDFDerivativesLockPtr, std::try_to_lock);
std::unique_lock<std::mutex> FirstTryLockHolder(*this->m_ParentJointPDFDerivativesMutexPtr, std::try_to_lock);
if (FirstTryLockHolder.owns_lock())
{
ReduceBuffer();
Expand All @@ -623,7 +623,7 @@ MattesMutualInformationImageToImageMetricv4<TFixedImage,
{
DoubleBufferSize();
// Attempt to acquire the lock a second time
std::unique_lock<std::mutex> SecondTryLockHolder(*this->m_ParentJointPDFDerivativesLockPtr, std::try_to_lock);
std::unique_lock<std::mutex> SecondTryLockHolder(*this->m_ParentJointPDFDerivativesMutexPtr, std::try_to_lock);
if (SecondTryLockHolder.owns_lock())
{
ReduceBuffer();
Expand Down Expand Up @@ -652,7 +652,7 @@ MattesMutualInformationImageToImageMetricv4<TFixedImage,
{
if (m_CurrentFillSize > 0)
{
const std::lock_guard<std::mutex> LockHolder(*this->m_ParentJointPDFDerivativesLockPtr);
const std::lock_guard<std::mutex> LockHolder(*this->m_ParentJointPDFDerivativesMutexPtr);
ReduceBuffer();
}
}
Expand Down

0 comments on commit 8149ba9

Please sign in to comment.