1228b4580SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3228b4580SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4228b4580SAndrew Rist * or more contributor license agreements. See the NOTICE file 5228b4580SAndrew Rist * distributed with this work for additional information 6228b4580SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7228b4580SAndrew Rist * to you under the Apache License, Version 2.0 (the 8228b4580SAndrew Rist * "License"); you may not use this file except in compliance 9228b4580SAndrew Rist * with the License. You may obtain a copy of the License at 10228b4580SAndrew Rist * 11228b4580SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12228b4580SAndrew Rist * 13228b4580SAndrew Rist * Unless required by applicable law or agreed to in writing, 14228b4580SAndrew Rist * software distributed under the License is distributed on an 15228b4580SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16228b4580SAndrew Rist * KIND, either express or implied. See the License for the 17228b4580SAndrew Rist * specific language governing permissions and limitations 18228b4580SAndrew Rist * under the License. 19228b4580SAndrew Rist * 20228b4580SAndrew Rist *************************************************************/ 21228b4580SAndrew Rist 22228b4580SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __FRAMEWORK_THREADHELP_IRWLOCK_H_ 25cdf0e10cSrcweir #define __FRAMEWORK_THREADHELP_IRWLOCK_H_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 28cdf0e10cSrcweir // includes 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir 31cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 32cdf0e10cSrcweir // namespace 33cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace framework{ 36cdf0e10cSrcweir 37cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 38cdf0e10cSrcweir // declarations 39cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 40cdf0e10cSrcweir 41cdf0e10cSrcweir /*-************************************************************************************************************//** 42cdf0e10cSrcweir @descr A guard (specialy a write guard) support different internal working states. 43cdf0e10cSrcweir His lock can set for reading or writing/reading! Or he was unlocked by user ... 44cdf0e10cSrcweir *//*-*************************************************************************************************************/ 45cdf0e10cSrcweir enum ELockMode 46cdf0e10cSrcweir { 47cdf0e10cSrcweir E_NOLOCK , 48cdf0e10cSrcweir E_READLOCK , 49cdf0e10cSrcweir E_WRITELOCK 50cdf0e10cSrcweir }; 51cdf0e10cSrcweir 52cdf0e10cSrcweir /*-************************************************************************************************************//** 53cdf0e10cSrcweir @descr We implement two guards for using an rw-lock. But if you wish to implement 54cdf0e10cSrcweir different rw-locks to you will have problems by using with same guard implementation! 55*796b7e2aSmseidel That's why we define this "pure virtual base class" ... 56cdf0e10cSrcweir All rw-locks must support this base interface for working and all guard must use this one too! 57cdf0e10cSrcweir *//*-*************************************************************************************************************/ 58cdf0e10cSrcweir class IRWLock 59cdf0e10cSrcweir { 60cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 61cdf0e10cSrcweir // public methods 62cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 63cdf0e10cSrcweir public: 64cdf0e10cSrcweir 65cdf0e10cSrcweir /*-****************************************************************************************************//** 66cdf0e10cSrcweir @descr These functions must be supported by a derived class! 67cdf0e10cSrcweir acquireReadAccess() -try to register thread as reader 68cdf0e10cSrcweir releaseReadAccess() -unregister thread as reader 69cdf0e10cSrcweir acquireWriteAccess() -try to register thread as writer 70cdf0e10cSrcweir releaseWriteAccess() -unregister thread as writer 71cdf0e10cSrcweir downgradeWriteAccess() -make writer to reader 72cdf0e10cSrcweir *//*-*****************************************************************************************************/ 73cdf0e10cSrcweir virtual void acquireReadAccess () =0; 74cdf0e10cSrcweir virtual void releaseReadAccess () =0; 75cdf0e10cSrcweir virtual void acquireWriteAccess () =0; 76cdf0e10cSrcweir virtual void releaseWriteAccess () =0; 77cdf0e10cSrcweir virtual void downgradeWriteAccess () =0; 78cdf0e10cSrcweir 79cdf0e10cSrcweir }; // class IRWLock 80cdf0e10cSrcweir 81cdf0e10cSrcweir } // namespace framework 82cdf0e10cSrcweir 83cdf0e10cSrcweir #endif // #ifndef __FRAMEWORK_THREADHELP_IRWLOCK_H_ 84