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-2014 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 00064 class SbThreadSignal 00065 { 00066 public: 00067 00071 SbThreadSignal( SbThreadMutex* mtx ); 00072 00076 ~SbThreadSignal( ); 00077 00081 void signalOne( ); 00082 00087 void signalAll( ); 00088 00094 void wait( ); 00095 00101 SbBool trywait( const unsigned int timeout_ms ); 00102 00103 private: 00104 SbThreadMutex* m_signalMtx; 00105 00106 #if defined(_WIN32) 00107 HANDLE m_events[2]; 00108 uint32_t m_waitersCount; 00109 SbThreadSpinlock m_spinlock; 00110 00111 #elif defined (__linux__) || defined(__APPLE__) 00112 pthread_cond_t m_event; 00113 bool m_automatic; 00114 bool m_active; 00115 00116 #else 00117 // Not implemented yet. 00118 #endif 00119 }; 00120 00121 #endif // SB_THREAD_SIGNAL_H 00122 00123 00124 00125 00126