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-2017 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : Julien Chaplier (MMM yyyy) 00022 **=======================================================================*/ 00023 00024 #ifndef _SB_THREAD_RW_MUTEX_H_ 00025 #define _SB_THREAD_RW_MUTEX_H_ 00026 00027 #if defined(_WIN32) 00028 #pragma warning( push ) 00029 #pragma warning( disable: 4251 ) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' 00030 #endif 00031 00032 #include <Inventor/SbBase.h> 00033 #include <Inventor/SbPImpl.h> 00034 00035 // keep this header for compatibility purpose 00036 #include <Inventor/threads/SbThread.h> 00037 #include <Inventor/threads/SbThreadSpinlock.h> 00038 #include <Inventor/threads/SbThreadAutoLock.h> 00039 00040 SO_PIMPL_BASE_PUBLIC_DECLARATION(SbThreadRWMutex) 00041 00042 00093 class SbThreadRWMutex 00094 { 00095 SO_PIMPL_BASE_PUBLIC_HEADER( SbThreadRWMutex ); 00096 00097 public: 00101 SbThreadRWMutex(); 00102 00103 #if 1 SoDEPRECATED 00105 SbThreadRWMutex( const SbBool force ); 00106 #endif 00111 ~SbThreadRWMutex(); 00112 00117 int writelock(); 00118 00122 int writeunlock(); 00123 00128 int readlock(); 00129 00133 int readunlock(); 00134 00135 private: 00136 00137 // returns if someone has a lock on this mutex (even current thread) 00138 // it is particularly usefull to check if the mutex can be deleted or not. 00139 SbBool isUsed() const; 00140 00141 // version adapted for r/w try-locking. It is a little slower 00142 // than the regular trylock. Synonymous for trywritelock. No 00143 // trylock should be done within a readlock on the same mutex. 00144 // !!! Not fully implemented 00145 SbBool trywritelock(); 00146 00147 // Equivalent to readlock but does not block if the reader cannot 00148 // lock the mutex and returns FALSE. Otherwise returns TRUE. 00149 // !!! Not fully implemented 00150 SbBool tryreadlock(); 00151 00152 private: 00153 // no copy constructor 00154 SbThreadRWMutex(const SbThreadRWMutex&); 00155 }; 00156 00157 #if defined(_WIN32) 00158 #pragma warning( pop ) 00159 #endif 00160 00161 #endif //_SB_THREAD_RW_MUTEX_H_ 00162 00163 00164