GenericReadWriteLock.hGo to the documentation of this file.00001 /* 00002 * 00003 * 00004 * Copyright (c) 2000-2003 Barak Weichselbaum <barak@komodia.com> 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 00017 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00019 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 00020 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00021 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00022 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00023 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00024 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00025 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00026 * SUCH DAMAGE. 00027 * 00028 * 00029 * Contact info: 00030 * Site: http://www.komodia.com 00031 * Email: barak@komodia.com 00032 */ 00033 00034 #if !defined(AFX_GENERICREADWRITELOCK_H__BCA15B95_3F3D_48BA_8310_01DB58AB415F__INCLUDED_) 00035 #define AFX_GENERICREADWRITELOCK_H__BCA15B95_3F3D_48BA_8310_01DB58AB415F__INCLUDED_ 00036 00037 #if _MSC_VER > 1000 00038 #pragma once 00039 #endif // _MSC_VER > 1000 00040 00041 #include "KomodiaSettings.h" 00042 #include "RWAutoRelease.h" 00043 00044 KOMODIA_NAMESPACE_START 00045 00046 class CGenericReadWriteLock 00047 { 00048 public: 00049 //Lock for reading 00050 //Returns TRUE for timeout 00051 virtual BOOL LockRead(unsigned long ulMSTimeout=INFINITE)=0; 00052 00053 //Unlock for reading 00054 virtual void UnlockRead()=0; 00055 00056 //Lock for reading 00057 virtual BOOL LockWrite()=0; 00058 00059 //Unlock for writing 00060 virtual void UnlockWrite()=0; 00061 00062 //Escalate write priority 00063 virtual BOOL Escalate(unsigned long ulMSTimeout, 00064 unsigned long ulIterations)=0; 00065 00066 //Remove the escalation flag 00067 virtual void StopEscalation()=0; 00068 00069 //Ctor and Dtor 00070 //iMaximumReaders - Maximum readers in the same time 00071 CGenericReadWriteLock(int iMaximumReaders); 00072 virtual ~CGenericReadWriteLock(); 00073 protected: 00074 //Get the number of readers 00075 int GetMaximumReaders()const; 00076 private: 00077 //Number of readers 00078 int m_iMaximumReaders; 00079 }; 00080 00081 KOMODIA_NAMESPACE_END 00082 00083 #endif // !defined(AFX_GENERICREADWRITELOCK_H__BCA15B95_3F3D_48BA_8310_01DB58AB415F__INCLUDED_) |