Commit f7ca9402 authored by Julien Michel's avatar Julien Michel

ENH: Adding mutex to keep thread safety

parent f023ffd7
......@@ -26,6 +26,7 @@
#include "itkObjectFactory.h"
#include "itkIndex.h"
#include "itkSize.h"
#include "itkFastMutexLock.h"
namespace otb
{
......@@ -171,6 +172,9 @@ private:
// Is the splitter up-to-date ?
bool m_IsUpToDate;
// Lock to ensure thread-safety
itk::SimpleFastMutexLock m_Lock;
};
} // end namespace otb
......
......@@ -38,11 +38,13 @@ ImageRegionAdaptativeSplitter<VImageDimension>
this->SetRequestedNumberOfSplits(requestedNumber);
// Check if we need to compute split map agagin
m_Lock.Lock();
if(!m_IsUpToDate)
{
// Do so if we need to
this->EstimateSplitMap();
}
m_Lock.Unlock();
// Return the size of the split map
return m_StreamVector.size();
......@@ -57,11 +59,13 @@ ImageRegionAdaptativeSplitter<VImageDimension>
this->SetImageRegion(region);
// Check if we need to compute split map agagin
m_Lock.Lock();
if(!m_IsUpToDate)
{
// Do so if we need to
this->EstimateSplitMap();
}
m_Lock.Unlock();
// Return the requested split
return m_StreamVector.at(i);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment