Changeset 13041 for OpenSceneGraph/trunk/include/OpenThreads/ReadWriteMutex
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/OpenThreads/ReadWriteMutex
r12138 r13041 1 /* -*-c++-*- OpenThreads - Copyright (C) 1998-2007 Robert Osfield 1 /* -*-c++-*- OpenThreads - Copyright (C) 1998-2007 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 23 23 { 24 24 public: 25 25 26 26 ReadWriteMutex(): 27 27 _readCount(0) {} 28 28 29 29 virtual ~ReadWriteMutex() {} 30 30 31 31 virtual int readLock() 32 32 { … … 66 66 return _readWriteMutex.unlock(); 67 67 } 68 68 69 69 protected: 70 70 71 71 ReadWriteMutex(const ReadWriteMutex&) {} 72 72 ReadWriteMutex& operator = (const ReadWriteMutex&) { return *(this); } 73 73 74 74 #if 0 75 ReentrantMutex _readWriteMutex; 75 ReentrantMutex _readWriteMutex; 76 76 ReentrantMutex _readCountMutex; 77 77 #else 78 OpenThreads::Mutex _readWriteMutex; 78 OpenThreads::Mutex _readWriteMutex; 79 79 OpenThreads::Mutex _readCountMutex; 80 #endif 80 #endif 81 81 unsigned int _readCount; 82 82 83 83 }; 84 84 … … 86 86 { 87 87 public: 88 88 89 89 ScopedReadLock(ReadWriteMutex& mutex):_mutex(mutex) { _mutex.readLock(); } 90 90 ~ScopedReadLock() { _mutex.readUnlock(); } 91 92 protected: 91 92 protected: 93 93 ReadWriteMutex& _mutex; 94 94 … … 100 100 { 101 101 public: 102 102 103 103 ScopedWriteLock(ReadWriteMutex& mutex):_mutex(mutex) { _mutex.writeLock(); } 104 104 ~ScopedWriteLock() { _mutex.writeUnlock(); } 105 106 protected: 105 106 protected: 107 107 ReadWriteMutex& _mutex; 108 108
