16 #include <itkCommand.h> 22 m_ParameterListMutex = itk::FastMutexLock::New();
24 m_MultiThreader = itk::MultiThreader::New();
45 m_ParameterListMutex->Lock();
47 m_ParameterListMutex->Unlock();
53 if (value && m_TriggerPropertyConnections.find(parameter) == m_TriggerPropertyConnections.end())
55 itk::ReceptorMemberCommand<NonBlockingAlgorithm>::Pointer command =
56 itk::ReceptorMemberCommand<NonBlockingAlgorithm>::New();
59 m_TriggerPropertyConnections[parameter] = value->AddObserver(itk::ModifiedEvent(), command);
65 auto iter = m_TriggerPropertyConnections.find(parameter);
67 if (iter != m_TriggerPropertyConnections.end())
71 MITK_ERROR(!value) <<
"NonBlockingAlgorithm::UnDefineTriggerProperty() in bad state." << std::endl;
74 value->RemoveObserver(m_TriggerPropertyConnections[parameter]);
75 m_TriggerPropertyConnections.erase(iter);
93 m_ParameterListMutex->Lock();
96 m_ParameterListMutex->Unlock();
103 itk::ThreadFunctionType fpointer = &StaticNonBlockingAlgorithmThread;
104 m_ThreadID = m_MultiThreader->SpawnThread(fpointer, &m_ThreadParameters);
109 if (m_ThreadID == -1)
112 m_MultiThreader->TerminateThread(m_ThreadID);
116 ITK_THREAD_RETURN_TYPE NonBlockingAlgorithm::StaticNonBlockingAlgorithmThread(
void *param)
119 auto *itkmttis =
static_cast<itk::MultiThreader::ThreadInfoStruct *
>(param);
124 NonBlockingAlgorithm::Pointer algorithm = flsp->
m_Algorithm;
128 return ITK_THREAD_RETURN_VALUE;
131 algorithm->m_ParameterListMutex->Lock();
132 while (algorithm->m_UpdateRequests > 0)
134 algorithm->m_UpdateRequests = 0;
135 algorithm->m_ParameterListMutex->Unlock();
138 if (algorithm->ThreadedUpdateFunction())
140 itk::ReceptorMemberCommand<NonBlockingAlgorithm>::Pointer command =
141 itk::ReceptorMemberCommand<NonBlockingAlgorithm>::New();
148 itk::ReceptorMemberCommand<NonBlockingAlgorithm>::Pointer command =
149 itk::ReceptorMemberCommand<NonBlockingAlgorithm>::New();
155 algorithm->m_ParameterListMutex->Lock();
157 algorithm->m_ParameterListMutex->Unlock();
159 return ITK_THREAD_RETURN_VALUE;
174 m_ParameterListMutex->Lock();
176 m_ParameterListMutex->Unlock();
191 m_ParameterListMutex->Lock();
193 m_ParameterListMutex->Unlock();
itk::SmartPointer< NonBlockingAlgorithm > m_Algorithm
Data management class that handles 'was created by' relations.
Base of all data objects.
virtual void Initialize(const NonBlockingAlgorithm *other=nullptr)
DataCollection - Class to facilitate loading/accessing structured data.
WeakPointer< DataStorage > m_DataStorage
virtual void ThreadedUpdateSuccessful()
virtual bool ThreadedUpdateFunction()
DataStorage * GetDataStorage()
Abstract base class for properties.
virtual bool ReadyToRun()
void DefineTriggerParameter(const char *)
void CallThisFromGUIThread(itk::Command *, itk::EventObject *e=nullptr)
Change the current application cursor.
static CallbackFromGUIThread * GetInstance()
This class is a singleton.
PropertyList::Pointer m_Parameters
void UnDefineTriggerParameter(const char *)
void TriggerParameterModified(const itk::EventObject &)
void SetDataStorage(DataStorage &storage)
virtual void ThreadedUpdateFailed()
void SetPointerParameter(const char *parameter, const itk::SmartPointer< T > &value)
For any kind of smart pointers.
void StartBlockingAlgorithm()
~NonBlockingAlgorithm() override