VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkThreadMessager.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00022 #ifndef __vtkThreadMessager_h 00023 #define __vtkThreadMessager_h 00024 00025 #include "vtkObject.h" 00026 00027 #if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS) 00028 #include <pthread.h> // Needed for pthread types 00029 #endif 00030 00031 class VTK_COMMON_EXPORT vtkThreadMessager : public vtkObject 00032 { 00033 public: 00034 static vtkThreadMessager *New(); 00035 00036 vtkTypeMacro(vtkThreadMessager,vtkObject); 00037 void PrintSelf(ostream& os, vtkIndent indent); 00038 00040 void WaitForMessage(); 00041 00043 void SendWakeMessage(); 00044 00048 void EnableWaitForReceiver(); 00049 00053 void DisableWaitForReceiver(); 00054 00057 void WaitForReceiver(); 00058 00059 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE 00060 # define SendMessageA SendMessage 00061 # define SendMessageW SendMessage 00062 #endif 00063 00066 VTK_LEGACY(void SendMessage()); 00067 00068 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE 00069 # undef SendMessageW 00070 # undef SendMessageA 00071 //BTX 00072 VTK_LEGACY(void SendMessageA()); 00073 VTK_LEGACY(void SendMessageW()); 00074 //ETX 00075 #endif 00076 00077 protected: 00078 vtkThreadMessager(); 00079 ~vtkThreadMessager(); 00080 00081 #ifdef VTK_USE_PTHREADS 00082 pthread_mutex_t Mutex; 00083 pthread_cond_t PSignal; 00084 #endif 00085 00086 #ifdef VTK_USE_WIN32_THREADS 00087 vtkWindowsHANDLE WSignal; 00088 #endif 00089 00090 private: 00091 vtkThreadMessager(const vtkThreadMessager&); // Not implemented. 00092 void operator=(const vtkThreadMessager&); // Not implemented. 00093 }; 00094 00095 #endif 00096 00097 00098 00099 00100