ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkThreadJob.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 #ifndef itkThreadJob_h
20 #define itkThreadJob_h
21 
22 #include "itkMacro.h"
23 #include "itkThreadSupport.h"
24 
25 #if defined(ITK_USE_PTHREADS)
26 #include <pthread.h>
27 #include <semaphore.h>
28 #include <unistd.h> // for sleep
29 #elif defined(ITK_USE_WIN32_THREADS)
30 #include <windows.h>
31 #endif
32 
33 #if defined __APPLE__
34 #include <mach/mach_init.h>
35 #include <mach/mach_error.h>
36 #include <mach/semaphore.h>
37 #include <mach/task.h>
38 #include <mach/task_info.h>
39 #endif
40 
41 namespace itk
42 {
56 struct ThreadJob
57 {
58 public:
59 
60 #if defined(ITK_USE_PTHREADS) && defined(__APPLE__)
61  typedef semaphore_t Semaphore;
62 #elif defined(ITK_USE_WIN32_THREADS)
63  typedef HANDLE Semaphore;
64 #elif defined(ITK_USE_PTHREADS)
65  typedef sem_t Semaphore;
66 #else
67 #error Unknown thread system!
68 #endif
69 
71  m_ThreadFunction(ITK_NULLPTR),
72  m_Semaphore(ITK_NULLPTR),
73  m_UserData(ITK_NULLPTR)
74  {
75  }
76 
78  {
79  }
80 
81 
83 #if defined(_WIN32) || defined(_WIN64)
85 #else
86  void * (*m_ThreadFunction)(void *ptr);
87 #endif
88 
89 
91  Semaphore * m_Semaphore;
92 
94  void * m_UserData;
95 };
96 
97 } // end namespace itk
98 
99 #endif // itkThreadJob_h
void(* ThreadFunctionType)(void *)
This class is used to submit jobs to the thread pool.
Definition: itkThreadJob.h:56
void *(* m_ThreadFunction)(void *ptr)
Definition: itkThreadJob.h:86
void * m_UserData
Definition: itkThreadJob.h:94
Semaphore * m_Semaphore
Definition: itkThreadJob.h:91