16 mitk::ImageAccessorBase::ThreadIDType mitk::ImageAccessorBase::CurrentThreadHandle()
19 return GetCurrentThreadId();
22 #ifdef ITK_USE_PTHREADS 23 return pthread_self();
26 #ifdef ITK_USE_WIN32_THREADS 27 return GetCurrentThreadId();
31 bool mitk::ImageAccessorBase::CompareThreadHandles(mitk::ImageAccessorBase::ThreadIDType handle1,
32 mitk::ImageAccessorBase::ThreadIDType handle2)
34 return handle1 == handle2;
69 if (image->m_Initialized ==
false)
71 if (image->GetSource().IsNull())
73 mitkThrow() <<
"ImageAccessor: No image source is defined";
75 image->m_ReadWriteLock.Lock();
76 if (image->GetSource()->Updating() ==
false)
78 image->GetSource()->UpdateOutputInformation();
80 image->m_ReadWriteLock.Unlock();
87 if (imageDataItem ==
nullptr &&
m_SubRegion ==
nullptr)
92 image->m_ReadWriteLock.Lock();
93 imageDataItem = image->GetChannelData();
94 image->m_ReadWriteLock.Unlock();
114 mitkThrow() <<
"Invalid ImageAccessor: The use of a SubRegion is not supported (yet).";
120 mitkThrow() <<
"Invalid ImageAccessor: The use of a SubRegion is not supported (yet).";
137 (m_AddressEnd > iAB->
m_AddressBegin && m_AddressEnd <= iAB->m_AddressEnd))
144 GetImage()->m_ReadWriteLock.Unlock();
145 mitkThrow() <<
"ImageAccessor: incoherent memory area is not supported yet";
174 #ifdef MITK_USE_RECURSIVE_MUTEX_PREVENTION 176 ThreadIDType
id = CurrentThreadHandle();
177 if (CompareThreadHandles(
id, iAB->
m_Thread))
179 GetImage()->m_ReadWriteLock.Unlock();
181 <<
"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...
virtual const Image * GetImage() const =0
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()
mitk::Image::Pointer image
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...
int m_Options
Stores all extended properties of an ImageAccessor. The different flags in mitk::ImageAccessorBase::O...
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.