ITK  5.4.0
Insight Toolkit
itkPoolMultiThreader.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 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkPoolMultiThreader_h
29 #define itkPoolMultiThreader_h
30 
31 #include "itkMultiThreaderBase.h"
32 #include "itkThreadPool.h"
33 
34 namespace itk
35 {
45 class ITKCommon_EXPORT PoolMultiThreader : public MultiThreaderBase
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_MOVE(PoolMultiThreader);
49 
55 
57  itkNewMacro(Self);
58 
60  itkOverrideGetNameOfClassMacro(PoolMultiThreader);
61 
62 
67  void
68  SingleMethodExecute() override;
69 
74  void
75  SetSingleMethod(ThreadFunctionType, void * data) override;
76 
79  void
80  ParallelizeArray(SizeValueType firstIndex,
81  SizeValueType lastIndexPlus1,
83  ProcessObject * filter) override;
84 
86  void
87  ParallelizeImageRegion(unsigned int dimension,
88  const IndexValueType index[],
89  const SizeValueType size[],
91  ProcessObject * filter) override;
92 
95  void
96  SetMaximumNumberOfThreads(ThreadIdType numberOfThreads) override;
97 
98  struct ThreadPoolInfoStruct : WorkUnitInfo
99  {
100  std::future<ITK_THREAD_RETURN_TYPE> Future;
101  };
102 
103 protected:
105  ~PoolMultiThreader() override;
106  void
107  PrintSelf(std::ostream & os, Indent indent) const override;
108 
109 private:
110  // Thread pool instance and factory
111  ThreadPool::Pointer m_ThreadPool{};
112 
116  ThreadPoolInfoStruct m_ThreadInfoArray[ITK_MAX_THREADS]{};
117 
121  friend class ProcessObject;
122 };
123 
124 } // end namespace itk
125 #endif
itk::MultiThreaderBase
A class for performing multithreaded execution.
Definition: itkMultiThreaderBase.h:106
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ITK_MAX_THREADS
constexpr vcl_size_t ITK_MAX_THREADS
Definition: itkThreadSupport.h:79
itk::ThreadFunctionType
void(*)(void *) ThreadFunctionType
Definition: itkThreadSupport.h:82
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:90
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::PoolMultiThreader
A class for performing multithreaded execution with a thread pool back end.
Definition: itkPoolMultiThreader.h:45
itk::PoolMultiThreader::ThreadPoolInfoStruct
Definition: itkPoolMultiThreader.h:98
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkMultiThreaderBase.h
itkThreadPool.h
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::MultiThreaderBase::ThreadingFunctorType
std::function< void(const IndexValueType index[], const SizeValueType size[])> ThreadingFunctorType
Definition: itkMultiThreaderBase.h:332
itk::PoolMultiThreader::ThreadPoolInfoStruct::Future
std::future< ITK_THREAD_RETURN_TYPE > Future
Definition: itkPoolMultiThreader.h:100
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::MultiThreaderBase::ArrayThreadingFunctorType
std::function< void(SizeValueType)> ArrayThreadingFunctorType
Definition: itkMultiThreaderBase.h:333