Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CAT/CATCritSec.h Source File

CATCritSec.h

Go to the documentation of this file.
00001 /// \file    CATCritSec.h
00002 /// \brief Defines the interface to critical sections for thread synchronization.
00003 /// \ingroup CAT
00004 ///
00005 /// Copyright (c) 2008 by Michael Ellison.
00006 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00007 ///
00008 // $Author: mikeellison $
00009 // $Date: 2008-01-26 03:19:45 -0600 (Sat, 26 Jan 2008) $
00010 // $Revision:   $
00011 // $NoKeywords: $
00012 
00013 #ifndef _CATCritSec_H_
00014 #define _CATCritSec_H_
00015 
00016 #include "CATInternal.h"
00017 
00018 /// \class CATCritSec
00019 /// \brief Defines the interface to critical sections for thread synchronization.
00020 /// \ingroup CAT
00021 /// 
00022 /// CATCritSec provides a per-thread synchronization object.  While one thread
00023 /// owns a critical section, another may not receive it and will have to wait until
00024 /// it is released.  A single thread, however, will not be forced to wait
00025 /// if it tries to acquire the critical section twice before releasing it - just make
00026 /// sure to call Release() for each Wait().
00027 class CATCritSec
00028 {
00029    public:
00030       CATCritSec();
00031       virtual ~CATCritSec();
00032 
00033       /// Wait until the critical section is available.
00034       ///
00035       /// \sa Release()
00036       void Wait();
00037 
00038       /// Release() releases an acquired critical section.
00039       ///
00040       /// \sa Wait()
00041       void Release();
00042 
00043    private:
00044       CATCritSec& operator=(const CATCritSec&)
00045       {
00046          CATASSERT(false,"Copying critical sections is not supported.");
00047          return *this;
00048       }
00049 
00050       // Platform specific critical section handles
00051       CRITICAL_SECTION fCritSec;
00052 };
00053 
00054 
00055 #endif // _CATCritSec_H_
00056 
00057 

Generated on Mon Feb 11 04:09:42 2008 for Game Accessibility Suite by doxygen 1.5.4