18 #ifndef itkSemaphore_h
19 #define itkSemaphore_h
20 #if !defined( ITK_LEGACY_REMOVE )
25 #ifdef ITK_USE_UNIX_IPC_SEMAPHORES
28 #include <sys/types.h>
34 #ifndef ITK_USE_UNIX_IPC_SEMAPHORES
35 #ifdef ITK_USE_PTHREADS
39 #include <semaphore.h>
44 #ifdef ITK_USE_WIN32_THREADS
50 #ifdef ITK_USE_UNIX_IPC_SEMAPHORES
51 typedef int SemaphoreType;
54 #ifndef ITK_USE_UNIX_IPC_SEMAPHORES
55 #ifdef ITK_USE_PTHREADS
57 typedef sema_t SemaphoreType;
60 typedef sem_t *SemaphoreType;
62 typedef sem_t SemaphoreType;
68 #ifdef ITK_USE_WIN32_THREADS
69 typedef HANDLE SemaphoreType;
72 #ifndef ITK_USE_UNIX_IPC_SEMAPHORES
73 #ifndef ITK_USE_PTHREADS
74 #ifndef ITK_USE_WIN32_THREADS
75 typedef int SemaphoreType;
104 class Semaphore:
public LightObject
108 typedef Semaphore Self;
109 typedef LightObject Superclass;
117 itkTypeMacro(Semaphore, LightObject);
120 void Initialize(
unsigned int value);
143 std::string NeverUseThisCompilerWarningAvoidanceFunctionForPad1Pad2(
void)
const
145 return std::string(this->m_Pad1)+
"-"+std::string(this->m_Pad2);
150 #ifdef ITK_USE_UNIX_IPC_SEMAPHORES
153 static int m_IPCSemaphoreKey;
156 static SimpleMutexLock m_Mutex;
158 int UnixIpcSemaphoreCreate(
int unix_semaphore_key);
160 void UnixIpcSemaphoreRemove(
int sid);
162 void UnixIpcSemaphoreCall(
int sid,
int op);
164 void UnixIpcSemaphoreDown(
int sid);
166 void UnixIpcSemaphoreUp(
int sid);
173 SemaphoreType m_Sema;
179 std::string GetUniqueName();
181 static int m_SemaphoreCount;
182 std::string m_SemaphoreName;
186 #ifdef ITK_USE_PTHREADS
187 bool m_PThreadsSemaphoreRemoved;
192 #endif //#if !defined( ITK_LEGACY_REMOVE )