1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __FRAMEWORK_THREADHELP_IRWLOCK_H_ 29 #define __FRAMEWORK_THREADHELP_IRWLOCK_H_ 30 31 //_________________________________________________________________________________________________________________ 32 // includes 33 //_________________________________________________________________________________________________________________ 34 35 //_________________________________________________________________________________________________________________ 36 // namespace 37 //_________________________________________________________________________________________________________________ 38 39 namespace framework{ 40 41 //_________________________________________________________________________________________________________________ 42 // declarations 43 //_________________________________________________________________________________________________________________ 44 45 /*-************************************************************************************************************//** 46 @descr A guard (specialy a write guard) support different internal working states. 47 His lock can set for reading or writing/reading! Or he was unlocked by user ... 48 *//*-*************************************************************************************************************/ 49 enum ELockMode 50 { 51 E_NOLOCK , 52 E_READLOCK , 53 E_WRITELOCK 54 }; 55 56 /*-************************************************************************************************************//** 57 @descr We implement two guards for using an rw-lock. But if you wish to implement 58 different rw-locks to you will have problems by using with same guard implementation! 59 Thats why we define this "pure virtual base class" ... 60 All rw-locks must support this base interface for working and all guard must use this one too! 61 *//*-*************************************************************************************************************/ 62 class IRWLock 63 { 64 //------------------------------------------------------------------------------------------------------------- 65 // public methods 66 //------------------------------------------------------------------------------------------------------------- 67 public: 68 69 /*-****************************************************************************************************//** 70 @descr These functions must be supported by a derived class! 71 acquireReadAccess() -try to register thread as reader 72 releaseReadAccess() -unregister thread as reader 73 acquireWriteAccess() -try to register thread as writer 74 releaseWriteAccess() -unregister thread as writer 75 downgradeWriteAccess() -make writer to reader 76 *//*-*****************************************************************************************************/ 77 virtual void acquireReadAccess () =0; 78 virtual void releaseReadAccess () =0; 79 virtual void acquireWriteAccess () =0; 80 virtual void releaseWriteAccess () =0; 81 virtual void downgradeWriteAccess () =0; 82 83 }; // class IRWLock 84 85 } // namespace framework 86 87 #endif // #ifndef __FRAMEWORK_THREADHELP_IRWLOCK_H_ 88