<class name="QReadWriteLock" doc="/**
&lt;p&gt;The &lt;a href=&quot;QReadWriteLock.html#QReadWriteLock()&quot;&gt;&lt;tt&gt;QReadWriteLock&lt;/tt&gt;&lt;/a&gt; class provides read-write locking.&lt;/p&gt;
&lt;p&gt;A read-write lock is a synchronization tool for protecting resources that can be accessed for reading and writing. This type of lock is useful if you want to allow multiple threads to have simultaneous read-only access, but as soon as one thread wants to write to the resource, all other threads must be blocked until the writing is complete.&lt;/p&gt;
&lt;p&gt;In many cases, &lt;a href=&quot;QReadWriteLock.html#QReadWriteLock()&quot;&gt;&lt;tt&gt;QReadWriteLock&lt;/tt&gt;&lt;/a&gt; is a direct competitor to &lt;a href=&quot;%2E%2E/core/QMutex.html&quot;&gt;&lt;tt&gt;QMutex&lt;/tt&gt;&lt;/a&gt;. &lt;a href=&quot;QReadWriteLock.html#QReadWriteLock()&quot;&gt;&lt;tt&gt;QReadWriteLock&lt;/tt&gt;&lt;/a&gt; is a good choice if there are many concurrent reads and writing occurs infrequently.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;    QReadWriteLock lock;

    void ReaderThread::run()
    {
        ...
        lock.lockForRead();
        read_file();
        lock.unlock();
        ...
    }

    void WriterThread::run()
    {
        ...
        lock.lockForWrite();
        write_file();
        lock.unlock();
        ...
    }&lt;/pre&gt;
&lt;p&gt;To ensure that writers aren't blocked forever by readers, readers attempting to obtain a lock will not succeed if there is a blocked writer waiting for access, even if the lock is currently only accessed by other readers. Also, if the lock is accessed by a writer and another writer comes in, that writer will have priority over any readers that might also be waiting.&lt;/p&gt;
&lt;p&gt;Like &lt;a href=&quot;%2E%2E/core/QMutex.html&quot;&gt;&lt;tt&gt;QMutex&lt;/tt&gt;&lt;/a&gt;, a &lt;a href=&quot;QReadWriteLock.html#QReadWriteLock()&quot;&gt;&lt;tt&gt;QReadWriteLock&lt;/tt&gt;&lt;/a&gt; can be recursively locked by the same thread. In such cases, &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt; must be called the same number of times &lt;a href=&quot;QReadWriteLock.html#lockForWrite()&quot;&gt;&lt;tt&gt;lockForWrite&lt;/tt&gt;&lt;/a&gt; or &lt;a href=&quot;QReadWriteLock.html#lockForRead()&quot;&gt;&lt;tt&gt;lockForRead&lt;/tt&gt;&lt;/a&gt; was called. Note that the lock type cannot be changed when trying to lock recursively, i.e&amp;#x2e; it is not possible to lock for reading in a thread that already has locked for writing (and vice versa).&lt;/p&gt;

@see &lt;tt&gt;QReadLocker&lt;/tt&gt;
@see &lt;tt&gt;QWriteLocker&lt;/tt&gt;
@see &lt;a href=&quot;%2E%2E/core/QMutex.html&quot;&gt;&lt;tt&gt;QMutex&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;%2E%2E/core/QSemaphore.html&quot;&gt;&lt;tt&gt;QSemaphore&lt;/tt&gt;&lt;/a&gt; */">
    <method name="public QReadWriteLock()" doc="/**
&lt;p&gt;Constructs a &lt;a href=&quot;QReadWriteLock.html#QReadWriteLock()&quot;&gt;&lt;tt&gt;QReadWriteLock&lt;/tt&gt;&lt;/a&gt; object.&lt;/p&gt;

@see &lt;a href=&quot;QReadWriteLock.html#lockForRead()&quot;&gt;&lt;tt&gt;lockForRead&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#lockForWrite()&quot;&gt;&lt;tt&gt;lockForWrite&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public final void lockForRead()" doc="/**
&lt;p&gt;Locks the lock for reading. This function will block the current thread if any thread (including the current) has locked for writing.&lt;/p&gt;

@see &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#lockForWrite()&quot;&gt;&lt;tt&gt;lockForWrite&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#tryLockForRead(int)&quot;&gt;&lt;tt&gt;tryLockForRead&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public final void lockForWrite()" doc="/**
&lt;p&gt;Locks the lock for writing. This function will block the current thread if another thread has locked for reading or writing.&lt;/p&gt;

@see &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#lockForRead()&quot;&gt;&lt;tt&gt;lockForRead&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#tryLockForWrite()&quot;&gt;&lt;tt&gt;tryLockForWrite&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public final boolean tryLockForRead()" doc="/**
&lt;p&gt;Attempts to lock for reading. If the lock was obtained, this function returns true, otherwise it returns false instead of waiting for the lock to become available, i.e&amp;#x2e; it does not block.&lt;/p&gt;
&lt;p&gt;The lock attempt will fail if another thread has locked for writing.&lt;/p&gt;
&lt;p&gt;If the lock was obtained, the lock must be unlocked with &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt; before another thread can successfully lock it.&lt;/p&gt;

@see &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#lockForRead()&quot;&gt;&lt;tt&gt;lockForRead&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public final boolean tryLockForRead(int timeout)" doc="/**
&lt;p&gt;Attempts to lock for reading. This function returns true if the lock was obtained; otherwise it returns false. If another thread has locked for writing, this function will wait for at most &lt;tt&gt;timeout&lt;/tt&gt; milliseconds for the lock to become available.&lt;/p&gt;
&lt;p&gt;Note: Passing a negative number as the &lt;tt&gt;timeout&lt;/tt&gt; is equivalent to calling &lt;a href=&quot;QReadWriteLock.html#lockForRead()&quot;&gt;&lt;tt&gt;lockForRead&lt;/tt&gt;&lt;/a&gt;, i.e&amp;#x2e; this function will wait forever until lock can be locked for reading when &lt;tt&gt;timeout&lt;/tt&gt; is negative.&lt;/p&gt;
&lt;p&gt;If the lock was obtained, the lock must be unlocked with &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt; before another thread can successfully lock it.&lt;/p&gt;

@see &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#lockForRead()&quot;&gt;&lt;tt&gt;lockForRead&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public final boolean tryLockForWrite(int timeout)" doc="/**
&lt;p&gt;Attempts to lock for writing. This function returns true if the lock was obtained; otherwise it returns false. If another thread has locked for reading or writing, this function will wait for at most &lt;tt&gt;timeout&lt;/tt&gt; milliseconds for the lock to become available.&lt;/p&gt;
&lt;p&gt;Note: Passing a negative number as the &lt;tt&gt;timeout&lt;/tt&gt; is equivalent to calling &lt;a href=&quot;QReadWriteLock.html#lockForWrite()&quot;&gt;&lt;tt&gt;lockForWrite&lt;/tt&gt;&lt;/a&gt;, i.e&amp;#x2e; this function will wait forever until lock can be locked for writing when &lt;tt&gt;timeout&lt;/tt&gt; is negative.&lt;/p&gt;
&lt;p&gt;If the lock was obtained, the lock must be unlocked with &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt; before another thread can successfully lock it.&lt;/p&gt;

@see &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#lockForWrite()&quot;&gt;&lt;tt&gt;lockForWrite&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public final boolean tryLockForWrite()" doc="/**
&lt;p&gt;Attempts to lock for writing. If the lock was obtained, this function returns true; otherwise, it returns false immediately.&lt;/p&gt;
&lt;p&gt;The lock attempt will fail if another thread has locked for reading or writing.&lt;/p&gt;
&lt;p&gt;If the lock was obtained, the lock must be unlocked with &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt; before another thread can successfully lock it.&lt;/p&gt;

@see &lt;a href=&quot;QReadWriteLock.html#unlock()&quot;&gt;&lt;tt&gt;unlock&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#lockForWrite()&quot;&gt;&lt;tt&gt;lockForWrite&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public final void unlock()" doc="/**
&lt;p&gt;Unlocks the lock.&lt;/p&gt;
&lt;p&gt;Attempting to unlock a lock that is not locked is an error, and will result in program termination.&lt;/p&gt;

@see &lt;a href=&quot;QReadWriteLock.html#lockForRead()&quot;&gt;&lt;tt&gt;lockForRead&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#lockForWrite()&quot;&gt;&lt;tt&gt;lockForWrite&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#tryLockForRead(int)&quot;&gt;&lt;tt&gt;tryLockForRead&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QReadWriteLock.html#tryLockForWrite()&quot;&gt;&lt;tt&gt;tryLockForWrite&lt;/tt&gt;&lt;/a&gt; */"/>
</class>
