[Insight-users] multithreaded programming updating a common variable

Luis Ibanez luis.ibanez at kitware.com
Tue May 3 16:20:46 EDT 2005


Hi Abhishek,

Yes, ITK provide classes for Mutex locks and Semaphores.

Please look at the following files in Insight/Code/Common:

itkBarrier.h
itkConditionVariable.h
itkFastMutexLock.h
itkLightObject.h
itkMetaDataObject.h
itkMultiThreader.h
itkMutexLock.h
itkMutexLockHolder.h
itkSemaphore.h
itkSimpleFastMutexLock.h


Also, look at the Statistics filter for an example on
how to use these classes for a multi-threaded filter.

      Insight/Code/BasicFilters/
               itkStatisticsImageFilter.txx


In particular you want to look at the methods:

    BeforeThreadedGenerateData();
    ThreadedGenerateData();
    AfterThreadedGenerateData();


Regards,


    Luis


-----------------
Abhishek wrote:
> Hello Everyone,
> 
>  
> 
> I am writing a multithreaded image filter and I want to update a common 
> variable ‘count’. Does ITK provide any macros/ classes for using a 
> mutex/semaphore? Please guide me the best way to go about it and if 
> there is any existing code in ITK I can use as a reference. Thanks,
> 
>  
> 
> -Cheers,
> 
> Abhishek
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users





More information about the Insight-users mailing list