20 mitk::ImageAccessorBase::ThreadIDType mitk::ImageAccessorBase::CurrentThreadHandle()
23 return GetCurrentThreadId();
26 #ifdef ITK_USE_PTHREADS
27 return pthread_self();
30 #ifdef ITK_USE_WIN32_THREADS
31 return GetCurrentThreadId();
35 bool mitk::ImageAccessorBase::CompareThreadHandles(mitk::ImageAccessorBase::ThreadIDType handle1,
36 mitk::ImageAccessorBase::ThreadIDType handle2)
38 return handle1 == handle2;
51 m_Options(OptionFlags),
52 m_CoherentMemory(false)
73 if (image->m_Initialized ==
false)
75 if (image->GetSource().IsNull())
77 mitkThrow() <<
"ImageAccessor: No image source is defined";
79 image->m_ReadWriteLock.Lock();
80 if (image->GetSource()->Updating() ==
false)
82 image->GetSource()->UpdateOutputInformation();
84 image->m_ReadWriteLock.Unlock();
91 if (imageDataItem ==
nullptr &&
m_SubRegion ==
nullptr)
96 image->m_ReadWriteLock.Lock();
97 imageDataItem = image->GetChannelData();
98 image->m_ReadWriteLock.Unlock();
118 mitkThrow() <<
"Invalid ImageAccessor: The use of a SubRegion is not supported (yet).";
124 mitkThrow() <<
"Invalid ImageAccessor: The use of a SubRegion is not supported (yet).";
133 if (m_CoherentMemory)
140 if ((m_AddressBegin >= iAB->
m_AddressBegin && m_AddressBegin < iAB->m_AddressEnd) ||
141 (m_AddressEnd > iAB->
m_AddressBegin && m_AddressEnd <= iAB->m_AddressEnd))
148 GetImage()->m_ReadWriteLock.Unlock();
149 mitkThrow() <<
"ImageAccessor: incoherent memory area is not supported yet";
178 #ifdef MITK_USE_RECURSIVE_MUTEX_PREVENTION
180 ThreadIDType
id = CurrentThreadHandle();
181 if (CompareThreadHandles(
id, iAB->
m_Thread))
183 GetImage()->m_ReadWriteLock.Unlock();
185 <<
"Prohibited image access: the requested image part is already in use and cannot be requested recursively!";
void WaitForReleaseOf(ImageAccessorWaitLock *wL)
Uses the WaitLock to wait for another ImageAccessor.
itk::ImageRegion< 4 > * m_SubRegion
unsigned int m_WaiterCount
Holds the number of ImageAccessors, which are waiting until the represented ImageAccessor is released...
bool Overlap(const ImageAccessorBase *iAB)
Computes if there is an Overlap of the image part between this instantiation and another ImageAccesso...
ImageAccessorWaitLock * m_WaitLock
Pointer to a WaitLock struct, that allows other ImageAccessors to wait for this ImageAccessor.
virtual ~ImageAccessorBase()
void PreventRecursiveMutexLock(ImageAccessorBase *iAB)
Prevents a recursive mutex lock by comparing thread ids of competing image accessors.
ImageAccessorBase(ImageConstPointer iP, const ImageDataItem *iDI=nullptr, int OptionFlags=DefaultBehavior)
Checks validity of given parameters from inheriting classes and stores those parameters in member var...
itk::SimpleFastMutexLock m_Mutex
A mutex that allows other ImageAccessors to wait for the represented ImageAccessor.
This struct allows to make ImageAccessors wait for this particular ImageAccessor object.
Internal class for managing references on sub-images.