亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? qreadwritelock.cpp

?? QT 開發環境里面一個很重要的文件
?? CPP
字號:
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the QtCore module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qplatformdefs.h"#include "qreadwritelock.h"#ifndef QT_NO_THREAD#include "qmutex.h"#include "qwaitcondition.h"struct QReadWriteLockPrivate{    QReadWriteLockPrivate()    : accessCount(0), waitingReaders(0), waitingWriters(0) {}        QMutex mutex;    QWaitCondition readerWait;    QWaitCondition writerWait;       int accessCount;    int waitingReaders;    int waitingWriters;};/*! \class QReadWriteLock    \brief The QReadWriteLock class provides read-write locking.    \threadsafe    \ingroup thread    \ingroup environment    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.    In many cases, QReadWriteLock is a direct competitor to QMutex.    QReadWriteLock is a good choice if there are many concurrent    reads and writing occurs infrequently.    Example:    \code        QReadWriteLock lock;        void ReaderThread::run()        {            ...            lock.lockForRead();            read_file();            lock.unlock();            ...        }        void WriterThread::run()        {            ...            lock.lockForWrite();            write_file();            lock.unlock();            ...        }    \endcode    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.    \sa QReadLocker, QWriteLocker, QMutex, QSemaphore*//*!    Constructs a QReadWriteLock object.    \sa lockForRead(), lockForWrite()*/QReadWriteLock::QReadWriteLock()    :d(new QReadWriteLockPrivate()){}/*!    Destroys the QReadWriteLock object.    \warning Destroying a read-write lock that is in use may result    in undefined behavior.*/QReadWriteLock::~QReadWriteLock(){    delete d;}/*!    Locks the lock for reading. This function will block the current    thread if another thread has locked for writing.    \sa unlock() lockForWrite() tryLockForRead()*/void QReadWriteLock::lockForRead(){    QMutexLocker lock(&d->mutex);    while (d->accessCount < 0 || d->waitingWriters) {        ++d->waitingReaders;        d->readerWait.wait(&d->mutex);        --d->waitingReaders;     }    ++d->accessCount;    Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::lockForRead()", "Overflow in lock counter");}/*!    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. it does not block.    The lock attempt will fail if another thread has locked for    writing.    If the lock was obtained, the lock must be unlocked with unlock()    before another thread can successfully lock it.    \sa unlock() lockForRead()*/bool QReadWriteLock::tryLockForRead(){   QMutexLocker lock(&d->mutex);        if (d->accessCount < 0)        return false;        ++d->accessCount;    Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::lockForRead()", "Overflow in lock counter");        return true;} /*!    Locks the lock for writing. This function will block the current    thread if any thread has locked for reading or writing.    \sa unlock() lockForRead() tryLockForWrite() */void QReadWriteLock::lockForWrite(){    QMutexLocker lock(&d->mutex);    while (d->accessCount != 0) {        ++d->waitingWriters;        d->writerWait.wait(&d->mutex);        --d->waitingWriters;    }    d->accessCount = -1;}/*!    Attempts to lock for writing. If the lock was obtained, this    function returns true; otherwise, it returns false immediately.    The lock attempt will fail if any thread has locked for reading or    writing.    If the lock was obtained, the lock must be unlocked with unlock()    before another thread can successfully lock it.    \sa unlock() lockForWrite()*/bool QReadWriteLock::tryLockForWrite(){    QMutexLocker lock(&d->mutex);        if (d->accessCount != 0)        return false;        d->accessCount = -1;    return true;}/*!    Unlocks the lock.    Attempting to unlock a lock that is not locked is an error, and will result    in program termination.    \sa lockForRead() lockForWrite() tryLockForRead() tryLockForWrite()*/void QReadWriteLock::unlock(){    QMutexLocker lock(&d->mutex);        Q_ASSERT_X(d->accessCount != 0, "QReadWriteLock::unlock()", "Cannot unlock an unlocked lock");      if ((d->accessCount > 0 && --d->accessCount == 0) || (d->accessCount == -1 && ++d->accessCount == 0)) {        if (d->waitingWriters) {            d->writerWait.wakeOne();        } else if (d->waitingReaders) {            d->readerWait.wakeAll();        }   }      }/*!    \class QReadLocker    \brief The QReadLocker class is a convenience class that    simplifies locking and unlocking read-write locks for read access.    \threadsafe    \ingroup thread    \ingroup environment    The purpose of QReadLocker (and QWriteLocker) is to simplify    QReadWriteLock locking and unlocking. Locking and unlocking    statements or in exception handling code is error-prone and    difficult to debug. QReadLocker can be used in such situations    to ensure that the state of the lock is always well-defined.    Here's an example that uses QReadLocker to lock and unlock a    read-write lock for reading:    \code        QReadWriteLock lock;        QByteArray readData()        {            QReadLocker locker(&lock);            ...            return data;        }    \endcode    It is equivalent to the following code:    \code        QReadWriteLock lock;        QByteArray readData()        {            locker.lockForRead();            ...            locker.unlock();            return data;        }    \endcode    The QMutexLocker documentation shows examples where the use of a    locker object greatly simplifies programming.    \sa QWriteLocker, QReadWriteLock*//*!    \fn QReadLocker::QReadLocker(QReadWriteLock *lock)    Constructs a QReadLocker and locks \a lock for reading. The lock    will be unlocked when the QReadLocker is destroyed. If \c lock is    zero, QReadLocker does nothing.    \sa QReadWriteLock::lockForRead()*//*!    \fn QReadLocker::~QReadLocker()    Destroys the QReadLocker and unlocks the lock that was passed to    the constructor.    \sa QReadWriteLock::unlock()*//*!    \fn void QReadLocker::unlock()    Unlocks the lock associated with this locker.    \sa QReadWriteLock::unlock()*//*!    \fn void QReadLocker::relock()    Relocks an unlocked lock.    \sa unlock()*//*!    \fn QReadWriteLock *QReadLocker::readWriteLock() const    Returns a pointer to the read-write lock that was passed    to the constructor.*//*!    \class QWriteLocker    \brief The QWriteLocker class is a convenience class that    simplifies locking and unlocking read-write locks for write access.    \threadsafe    \ingroup thread    \ingroup environment    The purpose of QWriteLocker (and QReadLocker is to simplify    QReadWriteLock locking and unlocking. Locking and unlocking    statements or in exception handling code is error-prone and    difficult to debug. QWriteLocker can be used in such situations    to ensure that the state of the lock is always well-defined.    Here's an example that uses QWriteLocker to lock and unlock a    read-write lock for writing:    \code        QReadWriteLock lock;        void writeData(const QByteArray &data)        {            QWriteLocker locker(&lock);            ...        }    \endcode    It is equivalent to the following code:    \code        QReadWriteLock lock;        void writeData(const QByteArray &data)        {            locker.lockForWrite();            ...            locker.unlock();        }    \endcode    The QMutexLocker documentation shows examples where the use of a    locker object greatly simplifies programming.    \sa QReadLocker, QReadWriteLock*//*!    \fn QWriteLocker::QWriteLocker(QReadWriteLock *lock)    Constructs a QWriteLocker and locks \a lock for writing. The lock    will be unlocked when the QWriteLocker is destroyed. If \c lock is    zero, QWriteLocker does nothing.    \sa QReadWriteLock::lockForWrite()*//*!    \fn QWriteLocker::~QWriteLocker()    Destroys the QWriteLocker and unlocks the lock that was passed to    the constructor.    \sa QReadWriteLock::unlock()*//*!    \fn void QWriteLocker::unlock()    Unlocks the lock associated with this locker.    \sa QReadWriteLock::unlock()*//*!    \fn void QWriteLocker::relock()    Relocks an unlocked lock.    \sa unlock()*//*!    \fn QReadWriteLock *QWriteLocker::readWriteLock() const    Returns a pointer to the read-write lock that was passed    to the constructor.*/#endif // QT_NO_THREAD

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品久久综合| 欧美精品 国产精品| 久久久久国产精品免费免费搜索| 亚洲成人一区在线| 91国偷自产一区二区开放时间| 亚洲午夜私人影院| 日本道免费精品一区二区三区| 国产精品国产精品国产专区不蜜| 国产黄色精品网站| 国产清纯白嫩初高生在线观看91 | 一区二区三区四区在线| 高潮精品一区videoshd| 国产精品久久一级| 不卡的av在线播放| 一区二区激情小说| 成人激情电影免费在线观看| 国产精品三级av| 成人午夜在线播放| 一区二区三区在线免费视频 | 亚洲高清视频在线| 欧美精品自拍偷拍| 一区二区三区高清| 欧美一级生活片| 久久av资源网| 欧美精彩视频一区二区三区| 99国产精品久久久久久久久久 | 99久久婷婷国产精品综合| 亚洲免费在线看| 欧美午夜视频网站| 精品一区二区三区在线播放| 欧美成人女星排名| 成人精品国产福利| 亚洲风情在线资源站| 日韩午夜av一区| 另类小说视频一区二区| 国产精品久久久久久久久快鸭| 色狠狠综合天天综合综合| 日本欧美一区二区三区乱码 | 久久免费精品国产久精品久久久久 | 精品国产污污免费网站入口| 狠狠网亚洲精品| 亚洲日本一区二区三区| 欧美久久一区二区| 懂色av一区二区三区蜜臀 | 91在线精品秘密一区二区| 夜夜爽夜夜爽精品视频| 日韩女同互慰一区二区| 国产精品18久久久久| 亚洲欧美日韩国产一区二区三区 | 精品制服美女久久| 中国av一区二区三区| 欧洲中文字幕精品| 国产精品一二三四五| 亚洲午夜一区二区三区| 久久精品一区二区三区不卡牛牛| 91天堂素人约啪| 免费国产亚洲视频| 最新不卡av在线| 欧美日韩aaaaaa| 成人av电影免费在线播放| 同产精品九九九| 久久九九全国免费| 欧美一级一级性生活免费录像| 成人av在线资源网站| 亚洲一区二区三区在线播放| 久久伊人中文字幕| 欧美视频自拍偷拍| 99re在线精品| 国产精品自拍在线| 日韩电影免费一区| 日韩精品一二区| 秋霞电影网一区二区| 免费观看在线综合| 久久综合综合久久综合| 激情丁香综合五月| 寂寞少妇一区二区三区| 久久草av在线| 国产精品综合二区| 成人精品国产福利| 色丁香久综合在线久综合在线观看| 不卡的av在线播放| 色噜噜久久综合| 欧美在线视频你懂得| 欧美人与性动xxxx| 日韩欧美色电影| 日本一区二区三区久久久久久久久不 | 久久久久国产精品人| 国产网红主播福利一区二区| 国产人成一区二区三区影院| 欧美极品少妇xxxxⅹ高跟鞋| 亚洲天堂精品在线观看| 亚洲va韩国va欧美va精品| 久久99蜜桃精品| 国产99久久久国产精品| 91成人免费在线| 91精品国产综合久久精品| 久久精品视频一区二区| 亚洲日本在线a| 日本色综合中文字幕| 国产一区二区三区黄视频| 99热精品一区二区| 91麻豆精品国产91| 欧美高清在线视频| 亚洲成人www| 国产麻豆9l精品三级站| 99精品在线免费| 日韩一级片网站| 国产精品国产自产拍在线| 午夜亚洲国产au精品一区二区| 国产主播一区二区三区| 在线亚洲一区二区| 精品久久久久久久久久久院品网| 国产精品天干天干在线综合| 午夜精彩视频在线观看不卡| 国产精品一区二区不卡| 欧美三级视频在线播放| 久久精品夜色噜噜亚洲aⅴ| 亚洲欧美在线观看| 精品一区二区三区av| 久久久久久久久久久久久女国产乱 | 国产白丝精品91爽爽久久| 欧美亚洲国产一区二区三区va| 久久嫩草精品久久久久| 香蕉加勒比综合久久| 国产99久久久国产精品潘金| 这里只有精品免费| 一区精品在线播放| 国产一区不卡精品| 欧美精品黑人性xxxx| 综合婷婷亚洲小说| 激情久久五月天| 这里是久久伊人| 亚洲一区二区在线免费看| 成人av网在线| 久久久午夜电影| 日本中文字幕一区| 在线观看成人免费视频| 国产精品成人一区二区艾草 | 欧美剧情片在线观看| 亚洲三级免费观看| 岛国精品在线观看| 久久精品在线观看| 久久99精品久久久久久国产越南| 欧美日韩视频在线一区二区| 国产精品久久久久久妇女6080| 国产综合久久久久久久久久久久| 欧美老年两性高潮| 亚洲午夜精品一区二区三区他趣| 成人黄色在线看| 久久日韩粉嫩一区二区三区| 久久国产精品免费| 欧美一区二区人人喊爽| 亚洲成人777| 欧美人牲a欧美精品| 亚洲妇熟xx妇色黄| 欧美午夜精品免费| 亚洲一区二区三区激情| 欧亚洲嫩模精品一区三区| 亚洲欧美日韩国产综合在线| av网站一区二区三区| 国产精品电影一区二区三区| 成人av综合在线| 综合久久给合久久狠狠狠97色| 高清国产午夜精品久久久久久| 国产欧美精品一区| 成人精品高清在线| 亚洲欧美经典视频| 色成年激情久久综合| 亚洲一区二区成人在线观看| 欧美中文字幕一区二区三区 | 国产精品一区2区| 欧美激情一区不卡| 不卡的电视剧免费网站有什么| 综合电影一区二区三区| 91蜜桃传媒精品久久久一区二区| 亚洲女人小视频在线观看| 色婷婷av一区二区三区大白胸| 亚洲精品五月天| 欧美色视频一区| 麻豆一区二区99久久久久| 欧美大片拔萝卜| 激情综合网天天干| 亚洲国产成人私人影院tom| 97se亚洲国产综合自在线观| 亚洲综合久久av| 日韩亚洲欧美一区二区三区| 精品无人码麻豆乱码1区2区 | 久久久另类综合| 成人深夜视频在线观看| 亚洲精品乱码久久久久久久久 | 99久久婷婷国产综合精品| 亚洲在线视频免费观看| 91精品久久久久久久99蜜桃| 国产一区二区三区香蕉| 国产精品久久久久7777按摩| 欧美日韩精品三区| 韩国欧美一区二区| 一级日本不卡的影视| 亚洲精品一区二区三区福利 | 美女在线视频一区|