00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : Nicolas DAGUISE (May 2007) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef SB_THREAD_SIGNAL_H 00026 #define SB_THREAD_SIGNAL_H 00027 00028 #include <Inventor/sys/port.h> 00029 #include <Inventor/SbBase.h> 00030 00031 #include <Inventor/threads/SbThreadSpinlock.h> 00032 00033 class SbThreadMutex; 00034 00035 #if !defined (WIN32) 00036 #include <pthread.h> 00037 #endif 00038 00068 class SbThreadSignal 00069 { 00070 public: 00071 00075 SbThreadSignal( SbThreadMutex* mtx ); 00076 00080 ~SbThreadSignal( ); 00081 00085 void signalOne( ); 00086 00091 void signalAll( ); 00092 00098 void wait( ); 00099 00105 SbBool trywait( const unsigned int timeout_ms ); 00106 00107 private: 00108 SbThreadMutex* m_signalMtx; 00109 00110 #if defined(_WIN32) 00111 HANDLE m_events[2]; 00112 uint32_t m_waitersCount; 00113 SbThreadSpinlock m_spinlock; 00114 00115 #elif defined (__linux__) || defined(__APPLE__) || defined(sun) 00116 pthread_cond_t m_event; 00117 bool m_automatic; 00118 bool m_active; 00119 00120 #else 00121 // Not implemented yet. 00122 #endif 00123 }; 00124 00125 #endif // SB_THREAD_SIGNAL_H 00126 00127 00128 00129 00130