00001 /* 00002 * Copyright (C) 2006-2011, SRI International (R) 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #pragma once 00019 00020 #ifndef __OpenKarto_Mutex_h__ 00021 #define __OpenKarto_Mutex_h__ 00022 00023 #include <OpenKarto/Macros.h> 00024 00025 namespace karto 00026 { 00027 00029 00030 00034 00035 struct MutexPrivate; 00036 struct ScopedLockPrivate; 00037 00043 class KARTO_EXPORT Mutex 00044 { 00045 public: 00049 Mutex(); 00050 00054 ~Mutex(); 00055 00056 public: 00060 class KARTO_EXPORT ScopedLock 00061 { 00062 public: 00063 ScopedLock(); 00064 00069 ScopedLock(Mutex& rMutex); 00070 ~ScopedLock(); 00071 00072 public: 00077 void Acquire(Mutex& rMutex); 00078 00084 bool TryAcquire( Mutex& rMutex); 00085 00089 void Release(); 00090 00091 private: 00092 ScopedLockPrivate* m_pScopedLockPrivate; 00093 }; 00094 00095 private: 00096 // restrict the following functions 00097 Mutex(const Mutex&); 00098 void operator=(const Mutex&); 00099 00100 private: 00101 MutexPrivate* m_pMutexPrivate; 00102 }; 00103 00105 00106 } 00107 00108 #endif // __OpenKarto_Mutex_h__