Changeset 28353 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 15, 2010 12:26:45 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r27882 r28353 5 5 6 6 # 7 # Copyright (C) 2006-20 09Sun Microsystems, Inc.7 # Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 # 9 9 # This file is part of VirtualBox Open Source Edition (OSE), as … … 298 298 SnapshotImpl.cpp \ 299 299 MediumImpl.cpp \ 300 MediumLock.cpp \ 300 301 MediumAttachmentImpl.cpp \ 301 302 MediumFormatImpl.cpp \ -
trunk/src/VBox/Main/include/MediumLock.h
r27120 r28353 27 27 /* interface definitions */ 28 28 #include "VBox/com/VirtualBox.h" 29 #include "VirtualBoxBase.h" 30 #include "AutoCaller.h" 29 31 30 32 #include <iprt/types.h> 33 34 #include <list> 35 #include <map> 36 37 class Medium; 38 class MediumAttachment; 31 39 32 40 /** … … 54 62 * @param aLockWrite @c true means a write lock should be taken 55 63 */ 56 MediumLock(ComObjPtr<Medium> aMedium, bool aLockWrite); 64 MediumLock(const ComObjPtr<Medium> &aMedium, bool aLockWrite); 65 66 /** 67 * Copy constructor. Needed because we contain an AutoCaller 68 * instance which is deliberately not copyable. The copy is not 69 * marked as locked, so be careful. 70 * 71 * @param aMediumLock Reference to source object. 72 */ 73 MediumLock(const MediumLock &aMediumLock); 74 75 /** 76 * Update a medium lock description 77 * 78 * @note May be only used in unlocked state. 79 * 80 * @return COM status code 81 * @param aLockWrite @c true means a write lock should be taken 82 */ 83 HRESULT UpdateLock(bool aLockWrite); 84 85 /** 86 * Get medium object reference. 87 */ 88 const ComObjPtr<Medium> &GetMedium() const; 57 89 58 90 /** 59 91 * Acquire a medium lock. 60 */ 61 int Lock(); 92 * 93 * @return COM status code 94 */ 95 HRESULT Lock(); 62 96 63 97 /** 64 98 * Release a medium lock. 65 */ 66 int Unlock(); 99 * 100 * @return COM status code 101 */ 102 HRESULT Unlock(); 67 103 68 104 private: 69 105 ComObjPtr<Medium> mMedium; 106 AutoCaller mMediumCaller; 70 107 bool mLockWrite; 108 bool mIsLocked; 109 /** Flag whether the medium was skipped when taking the locks. 110 * Only existing and accessible media objects need to be locked. */ 111 bool mLockSkipped; 71 112 }; 72 113 … … 80 121 public: 81 122 123 /* Base list data type. */ 124 typedef std::list<MediumLock> Base; 125 82 126 /** 83 127 * Default medium lock list constructor. … … 91 135 92 136 /** 137 * Checks if medium lock declaration list is empty. 138 * 139 * @return true if list is empty. 140 */ 141 bool IsEmpty(); 142 143 /** 93 144 * Add a new medium lock declaration to the end of the list. 94 145 * 95 146 * @note May be only used in unlocked state. 96 147 * 97 * @return VBox status code.148 * @return COM status code 98 149 * @param aMedium Reference to medium object 99 150 * @param aLockWrite @c true means a write lock should be taken 100 151 */ 101 int Append(ComObjPtr<Medium>aMedium, bool aLockWrite);152 HRESULT Append(const ComObjPtr<Medium> &aMedium, bool aLockWrite); 102 153 103 154 /** … … 106 157 * @note May be only used in unlocked state. 107 158 * 108 * @return VBox status code.159 * @return COM status code 109 160 * @param aMedium Reference to medium object 110 161 * @param aLockWrite @c true means a write lock should be taken 111 162 */ 112 int Prepend(ComObjPtr<Medium>aMedium, bool aLockWrite);163 HRESULT Prepend(const ComObjPtr<Medium> &aMedium, bool aLockWrite); 113 164 114 165 /** … … 117 168 * @note May be only used in unlocked state. 118 169 * 119 * @return VBox status code.170 * @return COM status code 120 171 * @param aMedium Reference to medium object 121 172 * @param aLockWrite @c true means a write lock should be taken 122 173 */ 123 int Update(ComObjPtr<Medium> aMedium, bool aLockWrite); 124 125 /** 126 * Remove a medium lock declaration. 127 * 128 * @note May be only used in unlocked state. 129 * 130 * @return VBox status code. 131 * @param aMedium Reference to medium object 132 */ 133 int Remove(ComObjPtr<Medium> aMedium); 174 HRESULT Update(const ComObjPtr<Medium> &aMedium, bool aLockWrite); 175 176 /** 177 * Remove a medium lock declaration and return an updated iterator. 178 * 179 * @note May be used in locked state. 180 * 181 * @return COM status code 182 * @param aIt Iterator for the element to remove 183 */ 184 HRESULT RemoveByIterator(Base::iterator &aIt); 185 186 /** 187 * Clear all medium lock declaration. 188 * 189 * @note Implicitly unlocks all locks. 190 * 191 * @return COM status code 192 */ 193 HRESULT Clear(); 194 195 /** 196 * Get iterator begin() for base list. 197 */ 198 Base::iterator GetBegin(); 199 200 /** 201 * Get iterator end() for base list. 202 */ 203 Base::iterator GetEnd(); 134 204 135 205 /** 136 206 * Acquire all medium locks "atomically", i.e. all or nothing. 137 */ 138 int Lock(); 207 * 208 * @return COM status code 209 */ 210 HRESULT Lock(); 139 211 140 212 /** 141 213 * Release all medium locks. 142 */ 143 int Unlock(); 214 * 215 * @return COM status code 216 */ 217 HRESULT Unlock(); 144 218 145 219 private: 146 std::list<MediumLock>mMediumLocks;220 Base mMediumLocks; 147 221 bool mIsLocked; 148 } 222 }; 149 223 150 224 /** … … 163 237 164 238 /** 165 * Default medium lock list destructor.239 * Default medium lock list map destructor. 166 240 */ 167 241 ~MediumLockListMap(); 168 242 243 /** 244 * Checks if medium lock list map is empty. 245 * 246 * @return true if list is empty. 247 */ 248 bool IsEmpty(); 249 250 /** 251 * Insert a new medium lock list into the map. 252 * 253 * @note May be only used in unlocked state. 254 * 255 * @return COM status code 256 * @param aMediumAttachment Reference to medium attachment object, the key. 257 * @param aMediumLockList Reference to medium lock list object 258 */ 259 HRESULT Insert(const ComObjPtr<MediumAttachment> &aMediumAttachment, MediumLockList *aMediumLockList); 260 261 /** 262 * Replace the medium lock list key by a different one. 263 * 264 * @note May be used in locked state. 265 * 266 * @return COM status code 267 * @param aMediumAttachmentOld Reference to medium attachment object. 268 * @param aMediumAttachmentNew Reference to medium attachment object. 269 */ 270 HRESULT ReplaceKey(const ComObjPtr<MediumAttachment> &aMediumAttachmentOld, const ComObjPtr<MediumAttachment> &aMediumAttachmentNew); 271 272 /** 273 * Remove a medium lock list from the map. The list will get deleted. 274 * 275 * @note May be only used in unlocked state. 276 * 277 * @return COM status code 278 * @param aMediumAttachment Reference to medium attachment object, the key. 279 */ 280 HRESULT Remove(const ComObjPtr<MediumAttachment> &aMediumAttachment); 281 282 /** 283 * Clear all medium lock declarations in this map. 284 * 285 * @note Implicitly unlocks all locks. 286 * 287 * @return COM status code 288 */ 289 HRESULT Clear(); 290 291 /** 292 * Get the medium lock list identified by the given key. 293 * 294 * @note May be used in locked state. 295 * 296 * @return COM status code 297 * @param aMediumAttachment Key for medium attachment object. 298 * @param aMediumLockList Out: medium attachment object reference. 299 */ 300 HRESULT Get(const ComObjPtr<MediumAttachment> &aMediumAttachment, MediumLockList * &aMediumLockList); 301 302 /** 303 * Acquire all medium locks "atomically", i.e. all or nothing. 304 * 305 * @return COM status code 306 */ 307 HRESULT Lock(); 308 309 /** 310 * Release all medium locks. 311 * 312 * @return COM status code 313 */ 314 HRESULT Unlock(); 315 169 316 private: 170 std::map<ComObjPtr<Medium>, MediumLockList *> mMediumLocks; 171 } 317 typedef std::map<ComObjPtr<MediumAttachment>, MediumLockList *> Base; 318 Base mMediumLocks; 319 bool mIsLocked; 320 }; 172 321 173 322 #endif /* !____H_MEDIUMLOCK */
Note:
See TracChangeset
for help on using the changeset viewer.