Changeset 25288 in vbox
- Timestamp:
- Dec 10, 2009 12:30:09 AM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/AutoLock.cpp
r25287 r25288 24 24 #include "Logging.h" 25 25 26 #include <iprt/cdefs.h> 27 #include <iprt/critsect.h> 28 #include <iprt/thread.h> 29 #include <iprt/semaphore.h> 30 31 #include <iprt/err.h> 32 #include <iprt/assert.h> 33 34 #if defined(DEBUG) 35 # include <iprt/asm.h> // for ASMReturnAddress 36 #endif 37 26 38 #include <iprt/string.h> 27 39 … … 37 49 //////////////////////////////////////////////////////////////////////////////// 38 50 51 struct RWLockHandle::Data 52 { 53 Data() 54 { } 55 56 RTSEMRW sem; 57 }; 58 39 59 RWLockHandle::RWLockHandle() 40 60 { 41 int vrc = RTSemRWCreate (&mSemRW); 42 AssertRC (vrc); 43 } 44 45 46 RWLockHandle::~RWLockHandle() 47 { 48 RTSemRWDestroy (mSemRW); 49 } 50 51 52 bool RWLockHandle::isWriteLockOnCurrentThread() const 53 { 54 return RTSemRWIsWriteOwner (mSemRW); 55 } 56 57 58 void RWLockHandle::lockWrite() 59 { 60 int vrc = RTSemRWRequestWrite (mSemRW, RT_INDEFINITE_WAIT); 61 AssertRC (vrc); 62 } 63 64 65 void RWLockHandle::unlockWrite() 66 { 67 int vrc = RTSemRWReleaseWrite (mSemRW); 68 AssertRC (vrc); 69 } 70 71 72 void RWLockHandle::lockRead() 73 { 74 int vrc = RTSemRWRequestRead (mSemRW, RT_INDEFINITE_WAIT); 75 AssertRC (vrc); 76 } 77 78 79 void RWLockHandle::unlockRead() 80 { 81 int vrc = RTSemRWReleaseRead (mSemRW); 82 AssertRC (vrc); 83 } 84 85 86 uint32_t RWLockHandle::writeLockLevel() const 87 { 88 return RTSemRWGetWriteRecursion (mSemRW); 61 m = new Data(); 62 int vrc = RTSemRWCreate(&m->sem); 63 AssertRC(vrc); 64 } 65 66 /*virtual*/ RWLockHandle::~RWLockHandle() 67 { 68 RTSemRWDestroy(m->sem); 69 delete m; 70 } 71 72 /*virtual*/ bool RWLockHandle::isWriteLockOnCurrentThread() const 73 { 74 return RTSemRWIsWriteOwner(m->sem); 75 } 76 77 /*virtual*/ void RWLockHandle::lockWrite() 78 { 79 int vrc = RTSemRWRequestWrite(m->sem, RT_INDEFINITE_WAIT); 80 AssertRC(vrc); 81 } 82 83 /*virtual*/ void RWLockHandle::unlockWrite() 84 { 85 int vrc = RTSemRWReleaseWrite(m->sem); 86 AssertRC(vrc); 87 } 88 89 /*virtual*/ void RWLockHandle::lockRead() 90 { 91 int vrc = RTSemRWRequestRead(m->sem, RT_INDEFINITE_WAIT); 92 AssertRC(vrc); 93 } 94 95 /*virtual*/ void RWLockHandle::unlockRead() 96 { 97 int vrc = RTSemRWReleaseRead(m->sem); 98 AssertRC(vrc); 99 } 100 101 /*virtual*/ uint32_t RWLockHandle::writeLockLevel() const 102 { 103 return RTSemRWGetWriteRecursion(m->sem); 89 104 } 90 105 … … 95 110 //////////////////////////////////////////////////////////////////////////////// 96 111 112 struct WriteLockHandle::Data 113 { 114 Data() 115 { } 116 117 mutable RTCRITSECT sem; 118 }; 119 97 120 WriteLockHandle::WriteLockHandle() 98 121 { 99 RTCritSectInit(&mCritSect); 100 } 101 102 /*virtual*/ WriteLockHandle::~WriteLockHandle() 103 { 104 RTCritSectDelete(&mCritSect); 122 m = new Data; 123 RTCritSectInit(&m->sem); 124 } 125 126 WriteLockHandle::~WriteLockHandle() 127 { 128 RTCritSectDelete(&m->sem); 129 delete m; 105 130 } 106 131 107 132 /*virtual*/ bool WriteLockHandle::isWriteLockOnCurrentThread() const 108 133 { 109 return RTCritSectIsOwner(&m CritSect);134 return RTCritSectIsOwner(&m->sem); 110 135 } 111 136 … … 113 138 { 114 139 #if defined(DEBUG) 115 RTCritSectEnterDebug(&m CritSect,140 RTCritSectEnterDebug(&m->sem, 116 141 "WriteLockHandle::lockWrite() return address >>>", 117 0, (RTUINTPTR) 142 0, (RTUINTPTR)ASMReturnAddress()); 118 143 #else 119 RTCritSectEnter(&m CritSect);144 RTCritSectEnter(&m->sem); 120 145 #endif 121 146 } … … 123 148 /*virtual*/ void WriteLockHandle::unlockWrite() 124 149 { 125 RTCritSectLeave(&m CritSect);150 RTCritSectLeave(&m->sem); 126 151 } 127 152 … … 138 163 /*virtual*/ uint32_t WriteLockHandle::writeLockLevel() const 139 164 { 140 return RTCritSectGetRecursion(&m CritSect);165 return RTCritSectGetRecursion(&m->sem); 141 166 } 142 167 -
trunk/src/VBox/Main/include/AutoLock.h
r25287 r25288 23 23 #define ____H_AUTOLOCK 24 24 25 #include <iprt/cdefs.h>26 25 #include <iprt/types.h> 27 #include <iprt/critsect.h>28 #include <iprt/thread.h>29 #include <iprt/semaphore.h>30 31 #include <iprt/err.h>32 #include <iprt/assert.h>33 34 #if defined(DEBUG)35 # include <iprt/asm.h> // for ASMReturnAddress36 #endif37 38 #include <iprt/semaphore.h>39 26 40 27 namespace util … … 114 101 115 102 private: 116 RTSEMRW mSemRW; 103 struct Data; 104 Data *m; 117 105 }; 118 106 … … 144 132 145 133 private: 146 mutable RTCRITSECT mCritSect; 134 struct Data; 135 Data *m; 147 136 }; 148 137 -
trunk/src/VBox/Main/include/RemoteUSBBackend.h
r14949 r25288 27 27 #include <VBox/vrdpapi.h> 28 28 #include <VBox/vrdpusb.h> 29 30 #include <iprt/critsect.h> 29 31 30 32 //typedef enum -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r25200 r25288 24 24 25 25 #include <iprt/cdefs.h> 26 #include <iprt/thread.h> 26 27 27 28 #include <list>
Note:
See TracChangeset
for help on using the changeset viewer.