ITK  6.0.0
Insight Toolkit
itkDomainThreader.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkDomainThreader_h
19#define itkDomainThreader_h
20
21#include "itkObject.h"
23
24namespace itk
25{
26
65template <typename TDomainPartitioner, typename TAssociate>
66class ITK_TEMPLATE_EXPORT DomainThreader : public Object
67{
68public:
69 ITK_DISALLOW_COPY_AND_MOVE(DomainThreader);
70
76
77 using DomainPartitionerType = TDomainPartitioner;
78 using DomainType = typename DomainPartitionerType::DomainType;
79
80 using AssociateType = TAssociate;
81
83 itkOverrideGetNameOfClassMacro(DomainThreader);
84
90 void
91 Execute(AssociateType * enclosingClass, const DomainType & completeDomain);
92
94 itkSetObjectMacro(DomainPartitioner, DomainPartitionerType);
95 itkGetModifiableObjectMacro(DomainPartitioner, DomainPartitionerType);
100 itkGetConstMacro(NumberOfWorkUnitsUsed, ThreadIdType);
101
105
110 itkSetClampMacro(NumberOfWorkUnits, ThreadIdType, 1, ITK_MAX_THREADS);
111 itkGetConstMacro(NumberOfWorkUnits, ThreadIdType);
120 {
121 return this->m_MultiThreader->GetMaximumNumberOfThreads();
122 }
123 void
127protected:
129 ~DomainThreader() override = default;
130
133 virtual void
135
139 virtual void
141 {}
142
151 virtual void
152 ThreadedExecution(const DomainType & subdomain, const ThreadIdType threadId) = 0;
153
157 virtual void
159 {}
160
161 itkSetObjectMacro(MultiThreader, MultiThreaderBase);
162
167 ThreaderCallback(void * arg);
168
169 AssociateType * m_Associate{};
170
171private:
172 void
174
177 {
179 };
180
185 ThreadIdType m_NumberOfWorkUnitsUsed{ 0 };
186 ThreadIdType m_NumberOfWorkUnits{};
187 typename DomainPartitionerType::Pointer m_DomainPartitioner{};
188 DomainType m_CompleteDomain{};
189 MultiThreaderBase::Pointer m_MultiThreader{};
190};
191
192} // namespace itk
193
194#ifndef ITK_MANUAL_INSTANTIATION
195# include "itkDomainThreader.hxx"
196#endif
197
198#endif
Multi-threaded processing on a domain by processing sub-domains per thread.
void StartThreadingSequence()
MultiThreaderBase * GetMultiThreader() const
ThreadIdType GetMaximumNumberOfThreads() const
void Execute(AssociateType *enclosingClass, const DomainType &completeDomain)
TDomainPartitioner DomainPartitionerType
virtual void AfterThreadedExecution()
typename DomainPartitionerType::DomainType DomainType
virtual void ThreadedExecution(const DomainType &subdomain, const ThreadIdType threadId)=0
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ThreaderCallback(void *arg)
virtual void DetermineNumberOfWorkUnitsUsed()
~DomainThreader() override=default
virtual void BeforeThreadedExecution()
void SetMaximumNumberOfThreads(const ThreadIdType threads)
A class for performing multithreaded execution.
Base class for most ITK classes.
Definition: itkObject.h:62
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
constexpr vcl_size_t ITK_MAX_THREADS
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION