39 :
ImageAccessorBase(image.GetPointer(), iDI, OptionFlags), m_Image(image.GetPointer())
67 m_Image->m_ReadWriteLock.Lock();
70 auto it = std::find(m_Image->m_Readers.begin(), m_Image->m_Readers.end(),
this);
71 m_Image->m_Readers.erase(it);
74 if (m_WaitLock->m_WaiterCount <= 0)
76 m_WaitLock->m_Mutex.Unlock();
81 m_WaitLock->m_Mutex.Unlock();
84 m_Image->m_ReadWriteLock.Unlock();
94 return m_Image.GetPointer();
97 void mitk::ImageReadAccessor::OrganizeReadAccess()
99 m_Image->m_ReadWriteLock.Lock();
102 if (m_Image->m_Writers.size() > 0)
106 auto it = m_Image->m_Writers.begin();
108 for (; it != m_Image->m_Writers.end(); ++it)
116 if (!(m_Options & ExceptionIfLocked))
118 PreventRecursiveMutexLock(w);
122 m_Image->m_ReadWriteLock.Unlock();
126 OrganizeReadAccess();
132 m_Image->m_ReadWriteLock.Unlock();
134 <<
"The image part being ordered by the ImageAccessor is already in use and locked";
143 m_WaitLock->m_Mutex.Lock();
146 m_Image->m_Readers.push_back(
this);
150 m_Image->m_ReadWriteLock.Unlock();
virtual ~ImageReadAccessor()
virtual const Image * GetImage() const override
void WaitForReleaseOf(ImageAccessorWaitLock *wL)
Uses the WaitLock to wait for another ImageAccessor.
ImageAccessorWaitLock * m_WaitLock
Pointer to a WaitLock struct, that allows other ImageAccessors to wait for this ImageAccessor.
Image class for storing images.
ImageReadAccessor(ImageConstPointer image, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
Orders read access for a slice, volume or 4D-Image.
void Increment()
Increments m_WaiterCount. A call of this method is prohibited unless the Mutex m_ReadWriteLock in the...
#define mitkThrowException(classname)
Internal class for managing references on sub-images.