equal
deleted
inserted
replaced
1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtCore module of the Qt Toolkit. |
7 ** This file is part of the QtCore module of the Qt Toolkit. |
8 ** |
8 ** |
80 writer and another writer comes in, that writer will have |
80 writer and another writer comes in, that writer will have |
81 priority over any readers that might also be waiting. |
81 priority over any readers that might also be waiting. |
82 |
82 |
83 Like QMutex, a QReadWriteLock can be recursively locked by the |
83 Like QMutex, a QReadWriteLock can be recursively locked by the |
84 same thread when constructed in |
84 same thread when constructed in |
85 \l{QReadWriteLock::RecursionMode}recursive mode}. In such cases, |
85 \l{QReadWriteLock::RecursionMode}. In such cases, |
86 unlock() must be called the same number of times lockForWrite() or |
86 unlock() must be called the same number of times lockForWrite() or |
87 lockForRead() was called. Note that the lock type cannot be |
87 lockForRead() was called. Note that the lock type cannot be |
88 changed when trying to lock recursively, i.e. it is not possible |
88 changed when trying to lock recursively, i.e. it is not possible |
89 to lock for reading in a thread that already has locked for |
89 to lock for reading in a thread that already has locked for |
90 writing (and vice versa). |
90 writing (and vice versa). |
264 Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::tryLockForRead()", "Overflow in lock counter"); |
264 Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::tryLockForRead()", "Overflow in lock counter"); |
265 |
265 |
266 return true; |
266 return true; |
267 } |
267 } |
268 |
268 |
269 /*! |
269 /*! |
270 Locks the lock for writing. This function will block the current |
270 Locks the lock for writing. This function will block the current |
271 thread if another thread has locked for reading or writing. |
271 thread if another thread has locked for reading or writing. |
272 |
272 |
273 \sa unlock() lockForRead() tryLockForWrite() |
273 \sa unlock() lockForRead() tryLockForWrite() |
274 */ |
274 */ |
275 void QReadWriteLock::lockForWrite() |
275 void QReadWriteLock::lockForWrite() |
276 { |
276 { |
277 QMutexLocker lock(&d->mutex); |
277 QMutexLocker lock(&d->mutex); |
278 |
278 |
279 Qt::HANDLE self = 0; |
279 Qt::HANDLE self = 0; |