Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

SWMRG.h

Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 Module:  SWMRG.h
00004 Notices: Copyright (c) 2000 Jeffrey Richter
00005 ******************************************************************************/
00006 
00007 
00008 #pragma once
00009 
00010 
00012 
00018 class CSWMRG {
00019 public:
00020    CSWMRG();                 // Constructor
00021    ~CSWMRG();                // Destructor
00022 
00023    VOID WaitToRead();        // Call this to gain shared read access
00024    VOID WaitToWrite();       // Call this to gain exclusive write access
00025    VOID Done();              // Call this when done accessing the resource
00026 
00027 private:
00028    CRITICAL_SECTION m_cs;    // Permits exclusive access to other members
00029    HANDLE m_hsemReaders;     // Readers wait on this if a writer has access
00030    HANDLE m_hsemWriters;     // Writers wait on this if a reader has access
00031    int    m_nWaitingReaders; // Number of readers waiting for access
00032    int    m_nWaitingWriters; // Number of writers waiting for access
00033    int    m_nActive;         // Number of threads currently with access
00034                              //   (0=no threads, >0=# of readers, -1=1 writer)
00035 };
00036 
00037 

Generated on Mon Mar 25 06:29:59 2002 for Window Dressing by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001