@@ -75,11 +75,17 @@ class ITKCommon_EXPORT MultiThreaderBase : public Object
7575 /* * Run-time type information (and related methods). */
7676 itkTypeMacro (MultiThreaderBase, Object);
7777
78- /* * Get/Set the number of threads to create . It will be clamped to the range
78+ /* * Get/Set the number of threads to use . It will be clamped to the range
7979 * [ 1, m_GlobalMaximumNumberOfThreads ], so the caller of this method should
8080 * check that the requested number of threads was accepted. */
81- virtual void SetNumberOfThreads (ThreadIdType numberOfThreads);
82- itkGetConstMacro (NumberOfThreads, ThreadIdType);
81+ virtual void SetMaximumNumberOfThreads ( ThreadIdType numberOfThreads );
82+ itkGetConstMacro ( MaximumNumberOfThreads, ThreadIdType );
83+
84+ /* * Get/Set the number of work units to create. It might be clamped to the range
85+ * [ 1, SomeMaximumNumber ], so the caller of this method should
86+ * check that the requested number of work units was accepted. */
87+ virtual void SetNumberOfWorkUnits ( ThreadIdType numberOfWorkUnits );
88+ itkGetConstMacro ( NumberOfWorkUnits, ThreadIdType );
8389
8490 /* * Set/Get the maximum number of threads to use when multithreading. It
8591 * will be clamped to the range [ 1, ITK_MAX_THREADS ] because several arrays
@@ -149,27 +155,33 @@ class ITKCommon_EXPORT MultiThreaderBase : public Object
149155 /* * This is the structure that is passed to the thread that is
150156 * created from the SingleMethodExecute. It is passed in as a void *,
151157 * and it is up to the method to cast correctly and extract the information.
152- * The ThreadID is a number between 0 and NumberOfThreads -1 that
153- * indicates the id of this thread . The UserData is the
158+ * The WorkUnitID is a number between 0 and NumberOfWorkUnits -1 that
159+ * indicates the id of this work unit . The UserData is the
154160 * (void *)arg passed into the SetSingleMethod. */
155- struct ThreadInfoStruct
156- {
157- ThreadIdType ThreadID ;
158- ThreadIdType NumberOfThreads ;
159- void * UserData;
161+ struct WorkUnitInfo
162+ {
163+ ThreadIdType WorkUnitID ;
164+ ThreadIdType NumberOfWorkUnits ;
165+ void * UserData;
160166 ThreadFunctionType ThreadFunction;
161- enum { SUCCESS , ITK_EXCEPTION , ITK_PROCESS_ABORTED_EXCEPTION , STD_EXCEPTION , UNKNOWN } ThreadExitCode;
162- };
167+ enum
168+ {
169+ SUCCESS ,
170+ ITK_EXCEPTION ,
171+ ITK_PROCESS_ABORTED_EXCEPTION ,
172+ STD_EXCEPTION ,
173+ UNKNOWN
174+ } ThreadExitCode;
175+ };
163176
164177 /* * Execute the SingleMethod (as define by SetSingleMethod) using
165- * m_NumberOfThreads threads. As a side effect the m_NumberOfThreads will be
178+ * m_NumberOfWorkUnits threads. As a side effect the m_NumberOfWorkUnits will be
166179 * checked against the current m_GlobalMaximumNumberOfThreads and clamped if
167180 * necessary. */
168181 virtual void SingleMethodExecute () = 0;
169182
170183 /* * Set the SingleMethod to f() and the UserData field of the
171- * ThreadInfoStruct that is passed to it will be data.
172- * This method (and all the methods passed to SetMultipleMethod)
184+ * WorkUnitInfo that is passed to it will be data. This method
173185 * must be of type itkThreadFunctionType and must take a single argument of
174186 * type void *. */
175187 virtual void SetSingleMethod (ThreadFunctionType, void *data) = 0;
@@ -264,23 +276,25 @@ class ITKCommon_EXPORT MultiThreaderBase : public Object
264276
265277 static ITK_THREAD_RETURN_TYPE ParallelizeImageRegionHelper (void *arg);
266278
279+ /* * The number of work units to create. */
280+ ThreadIdType m_NumberOfWorkUnits;
281+
267282 /* * The number of threads to use.
268- * The m_NumberOfThreads must always be less than or equal to
283+ * The m_MaximumNumberOfThreads must always be less than or equal to
269284 * the m_GlobalMaximumNumberOfThreads before it is used during the execution
270- * of a threaded method. Its value is clamped in the SingleMethodExecute()
271- * and MultipleMethodExecute(). Its value is initialized to
285+ * of a threaded method. Its value is initialized to
272286 * m_GlobalDefaultNumberOfThreads at construction time. Its value is clamped
273287 * to the current m_GlobalMaximumNumberOfThreads in the
274- * SingleMethodExecute() and MultipleMethodExecute() methods .
288+ * SingleMethodExecute() method .
275289 */
276- ThreadIdType m_NumberOfThreads ;
290+ ThreadIdType m_MaximumNumberOfThreads ;
277291
278292 /* * Static function used as a "proxy callback" by multi-threaders. The
279- * threading library will call this routine for each thread, which
280- * will delegate the control to the prescribed SingleMethod. This
281- * routine acts as an intermediary between the multi-threaders and the
282- * user supplied callback (SingleMethod) in order to catch any
283- * exceptions thrown by the threads. */
293+ * threading library will call this routine for each thread, which
294+ * will delegate the control to the prescribed SingleMethod. This
295+ * routine acts as an intermediary between the multi-threaders and the
296+ * user supplied callback (SingleMethod) in order to catch any
297+ * exceptions thrown by the threads. */
284298 static ITK_THREAD_RETURN_TYPE SingleMethodProxy (void *arg);
285299
286300 /* * The method to invoke. */
@@ -300,5 +314,5 @@ class ITKCommon_EXPORT MultiThreaderBase : public Object
300314ITKCommon_EXPORT std::ostream& operator << (std::ostream& os,
301315 const MultiThreaderBase::ThreaderType& threader);
302316
303- } // end namespace itk
317+ } // end namespace itk
304318#endif
0 commit comments