Mutex.h

Go to the documentation of this file.
00001 #ifndef __LDK_MUTEX_H__
00002 #define __LDK_MUTEX_H__
00003 
00005 //   Copyright (C) 2003-2006 Lorien Dunn.
00006 //
00007 //   Contact: loriendunn AT users DOT sourceforge DOT net
00008 //
00009 //   This software is provided 'as-is', without any express or implied warranty.
00010 //   In no event will the authors be held liable for any damages arising from
00011 //   the use of this software.
00012 //
00013 //   Permission is granted to anyone to use this software for any purpose,
00014 //   including commercial applications, and to alter it and redistribute it
00015 //   freely, subject to the following restrictions:
00016 //
00017 //   1. The origin of this software must not be misrepresented; you must not
00018 //   claim that you wrote the original software. If you use this software in a
00019 //   product, an acknowledgment in the product documentation would be
00020 //   appreciated but is not required.
00021 //
00022 //   2. Altered source versions must be plainly marked as such, and must not be
00023 //   misrepresented as being the original software.
00024 //
00025 //   3. This notice may not be removed or altered from any source distribution.
00026 //
00028 
00029 #include "LDK/API.h"
00034 
00035 namespace LDK
00036 {
00042 class LDK_API Mutex
00043 {
00044 private:
00045     typedef void* MutexHandle;
00046     MutexHandle mHandle;
00047 public:
00049     Mutex();
00050 
00052     ~Mutex();
00053 
00057     void lock();
00058 
00060     void unlock();
00061 };
00062 
00068 class LDK_API Lock
00069 {
00070 private:
00071     Mutex& mMutex;
00072     inline Lock(const Lock& rhs) : mMutex(rhs.mMutex) {}
00073     inline void operator=(const Lock& rhs) {}
00074 public:
00077     inline Lock(Mutex& mtx) : mMutex(mtx) { mMutex.lock(); }
00078 
00080     inline ~Lock() { mMutex.unlock(); }
00081 };
00082 
00083 }//namespace LDK
00084 
00085 #endif //__LDK_MUTEX_H__

Generated on Fri Aug 17 18:32:26 2007 for LDK by  doxygen 1.5.1