BWAPI
trunk/bwapi/Util/Source/Util/Mutex.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 //
00004 //  A windows mutex or named mutex object
00005 //  Lockable with RAII
00006 //
00007 
00008 #include <windows.h>
00009 
00010 namespace Util
00011 {
00012   class Mutex
00013   {
00014 
00015           // constructors
00016   public:
00017           Mutex();
00018           Mutex(const char* systemName); // named mutex
00019           ~Mutex();
00020 
00021           // state
00022   private:
00023           HANDLE hMutex;
00024 
00025           // methods
00026   public:
00027           friend class Lock;
00028           class Lock
00029           {
00030                   // constructors
00031           public:
00032                   Lock(Mutex&);
00033                   Lock();
00034                   ~Lock();
00035 
00036 
00037                   // state
00038           private:
00039                   Mutex *target;
00040 
00041                   // methods
00042           public:
00043                   void lock(Mutex&);
00044                   bool tryLock(Mutex&);
00045                   void release();
00046           };
00047   };
00048 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines