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 : 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 00092 class SbThreadRWMutex 00093 { 00094 SO_PIMPL_BASE_PUBLIC_HEADER( SbThreadRWMutex ); 00095 00096 public: 00100 SbThreadRWMutex(const SbBool force = FALSE); 00101 00105 ~SbThreadRWMutex(); 00106 00111 int writelock(); 00112 00116 int writeunlock(); 00117 00122 int readlock(); 00123 00127 int readunlock(); 00128 00129 private: 00130 00131 // returns if someone has a lock on this mutex (even current thread) 00132 // it is particularly usefull to check if the mutex can be deleted or not. 00133 SbBool isUsed() const; 00134 00135 // version adapted for r/w try-locking. It is a little slower 00136 // than the regular trylock. Synonymous for trywritelock. No 00137 // trylock should be done within a readlock on the same mutex. 00138 // !!! Not fully implemented 00139 SbBool trywritelock(); 00140 00141 // Equivalent to readlock but does not block if the reader cannot 00142 // lock the mutex and returns FALSE. Otherwise returns TRUE. 00143 // !!! Not fully implemented 00144 SbBool tryreadlock(); 00145 00146 private: 00147 // no copy constructor 00148 SbThreadRWMutex(const SbThreadRWMutex&); 00149 }; 00150 00151 #if defined(_WIN32) 00152 #pragma warning( pop ) 00153 #endif 00154 00155 #endif //_SB_THREAD_RW_MUTEX_H_ 00156 00157 00158