19 OrganizeWriteAccess();
27 m_Image->m_ReadWriteLock.Lock();
30 auto it = std::find(m_Image->m_Writers.begin(), m_Image->m_Writers.end(),
this);
31 m_Image->m_Writers.erase(it);
44 m_Image->m_ReadWriteLock.Unlock();
49 return m_Image.GetPointer();
52 void mitk::ImageWriteAccessor::OrganizeWriteAccess()
54 m_Image->m_ReadWriteLock.Lock();
56 bool readOverlap =
false;
57 bool writeOverlap =
false;
62 if (m_Image->m_Readers.size() > 0)
66 auto it = m_Image->m_Readers.begin();
68 for (; it != m_Image->m_Readers.end(); ++it)
86 if (m_Image->m_Writers.size() > 0)
90 auto it = m_Image->m_Writers.begin();
92 for (; it != m_Image->m_Writers.end(); ++it)
111 if (readOverlap || writeOverlap)
119 m_Image->m_ReadWriteLock.Unlock();
123 OrganizeWriteAccess();
129 m_Image->m_ReadWriteLock.Unlock();
131 <<
"The image part being ordered by the ImageAccessor is already in use and locked";
142 m_Image->m_Writers.push_back(
this);
146 m_Image->m_ReadWriteLock.Unlock();
void WaitForReleaseOf(ImageAccessorWaitLock *wL)
Uses the WaitLock to wait for another ImageAccessor.
ImageWriteAccessor(ImagePointer image, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
Orders write access for a slice, volume or 4D-Image.
~ImageWriteAccessor() override
informs Image to unlock the represented image part
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.
Image class for storing images.
mitk::Image::Pointer image
void PreventRecursiveMutexLock(ImageAccessorBase *iAB)
Prevents a recursive mutex lock by comparing thread ids of competing image accessors.
#define mitkThrowException(classname)
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.
const Image * GetImage() const override