# Removed itkSemaphore

Bradley Lowekamp
2011-02-19
itk::Semaphore has been removed and placed in the deprecated module.

The implementation contained a mixture of thread semaphores and inter-process semaphores. This gives vastly different performance characteristics across platforms.

While you can simple continue using the old class, it is strongly recommended to update to use mutexes and conditional variables. By doing so you have the potential to take advantage of ITKv4 improved threading model.

ENH: removes semaphore in favor of mutex and conditional This was the only class in ITK which utilized a semaphore. This was replaced with the equivalent mutex and conditioanl variable.

itk::Semaphore::Pointer m_Semaphore = itk::Semaphore::New();

m_Semaphore->Up();

m_Semaphore->Down()
int m_Semaphore; SimpleMutexLock m_Lockl ConditionalVariable::Pointer m_Condition = ConditionalVariable::New();

m_Lock.Lock(); ++m_Semaphore; m_Condition->Signal(); m_Lock.Unlock();

m_Lock.Lock(); if ( m_Semaphore == 0 ) { m_Condition->Wait( & td.m_Lock); } --m_Semaphore; m_Lock.Unlock();
I5afecd8f29b07beed97534731e677214d1cceb3b I175f87493476d473a38f20f837479a7fe882230a
Code/Common/CMakeLists.txt Code/Common/itkSemaphore.cxx Code/Common/itkSemaphore.h Code/Common/itkSemaphoreNoThreads.cxx Code/Common/itkSemaphorePThreads.cxx Code/Common/itkSemaphoreWinThreads.cxx Testing/Code/Common/CMakeLists.txt Testing/Code/Common/itkCommonHeaderTest.cxx Testing/Code/Common/itkSemaphoreTest.cxx Code/BasicFilters/itkParallelSparseFieldLevelSetImageFilter.h Code/BasicFilters/itkParallelSparseFieldLevelSetImageFilter.txx