Changeset 8508 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 30, 2008 2:29:20 PM (17 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/AutoLock.cpp
r8424 r8508 27 27 { 28 28 29 29 30 RWLockHandle::RWLockHandle() 30 31 { … … 53 54 #endif /* VBOX_MAIN_USE_SEMRW */ 54 55 } 56 55 57 56 58 RWLockHandle::~RWLockHandle() … … 69 71 } 70 72 73 71 74 bool RWLockHandle::isWriteLockOnCurrentThread() const 72 75 { … … 85 88 } 86 89 90 87 91 void RWLockHandle::lockWrite() 88 92 { … … 100 104 if (mWriteLockThread != threadSelf) 101 105 { 106 # ifdef VBOX_MAIN_AUTOLOCK_TRAP 107 if (mReadLockCount != 0) 108 { 109 ReaderMap::const_iterator reader = mReaders.find (threadSelf); 110 if (reader != mReaders.end() && reader->second != 0) 111 { 112 AssertReleaseMsgFailedReturnVoid (( 113 "SELF DEADLOCK DETECTED on Thread %0x: lockWrite() after " 114 "lockRead(): reader count = %d!\n", 115 threadSelf, reader->second)); 116 } 117 } 118 # endif /* VBOX_MAIN_AUTOLOCK_TRAP */ 119 102 120 if (mReadLockCount != 0 || mWriteLockThread != NIL_RTNATIVETHREAD || 103 121 mWriteLockPending != 0 /* respect other pending writers */) … … 127 145 } 128 146 147 129 148 void RWLockHandle::unlockWrite() 130 149 { … … 163 182 } 164 183 184 165 185 void RWLockHandle::lockRead() 166 186 { … … 175 195 176 196 RTNATIVETHREAD threadSelf = RTThreadNativeSelf(); 197 198 # ifdef VBOX_MAIN_AUTOLOCK_TRAP 199 if (!mReaders.count (threadSelf)) 200 mReaders [threadSelf] = 0; 201 ++ mReaders [threadSelf]; 202 # endif /* VBOX_MAIN_AUTOLOCK_TRAP */ 177 203 178 204 bool isWriteLock = mWriteLockLevel != 0; … … 223 249 } 224 250 251 225 252 void RWLockHandle::unlockRead() 226 253 { … … 248 275 { 249 276 -- mSelfReadLockCount; 277 278 # ifdef VBOX_MAIN_AUTOLOCK_TRAP 279 -- mReaders [threadSelf]; 280 # endif /* VBOX_MAIN_AUTOLOCK_TRAP */ 250 281 } 251 282 } … … 264 295 RTSemEventSignal (mGoWriteSem); 265 296 } 266 } 267 } 268 269 RTCritSectLeave (&mCritSect); 270 271 #endif /* VBOX_MAIN_USE_SEMRW */ 272 } 297 298 # ifdef VBOX_MAIN_AUTOLOCK_TRAP 299 -- mReaders [threadSelf]; 300 # endif /* VBOX_MAIN_AUTOLOCK_TRAP */ 301 } 302 } 303 304 RTCritSectLeave (&mCritSect); 305 306 #endif /* VBOX_MAIN_USE_SEMRW */ 307 } 308 273 309 274 310 uint32_t RWLockHandle::writeLockLevel() const … … 287 323 } 288 324 325 289 326 } /* namespace util */ 290 327 -
trunk/src/VBox/Main/include/AutoLock.h
r8421 r8508 23 23 #define ____H_AUTOLOCK 24 24 25 /// @todo temporary 26 #define VBOX_MAIN_AUTOLOCK_TRAP 27 25 28 #include <iprt/cdefs.h> 26 29 #include <iprt/types.h> … … 38 41 #ifdef VBOX_MAIN_USE_SEMRW 39 42 # include <iprt/semaphore.h> 43 #else 44 # ifdef VBOX_MAIN_AUTOLOCK_TRAP 45 # include <map> 46 # endif 40 47 #endif 41 48 … … 198 205 uint32_t mWriteLockLevel; 199 206 uint32_t mWriteLockPending; 207 208 # ifdef VBOX_MAIN_AUTOLOCK_TRAP 209 210 typedef std::map <RTNATIVETHREAD, uint32_t> ReaderMap; 211 ReaderMap mReaders; 212 213 # endif /* VBOX_MAIN_AUTOLOCK_TRAP */ 200 214 201 215 #endif /* VBOX_MAIN_USE_SEMRW */
Note:
See TracChangeset
for help on using the changeset viewer.