当前位置: 首页>>代码示例>>C++>>正文


C++ QBasicAtomicInt::testAndSetRelease方法代码示例

本文整理汇总了C++中QBasicAtomicInt::testAndSetRelease方法的典型用法代码示例。如果您正苦于以下问题:C++ QBasicAtomicInt::testAndSetRelease方法的具体用法?C++ QBasicAtomicInt::testAndSetRelease怎么用?C++ QBasicAtomicInt::testAndSetRelease使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QBasicAtomicInt的用法示例。


在下文中一共展示了QBasicAtomicInt::testAndSetRelease方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: releaseTimerId

void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId)
{
    int which = timerId & 0x00ffffff;
    int bucket = bucketOffset(which);
    int at = bucketIndex(bucket, which);
    int *b = timerIds[bucket];

    int freeId, newTimerId;
    do {
        freeId = nextFreeTimerId;
        b[at] = freeId & 0x00ffffff;

        newTimerId = prepareNewValueWithSerialNumber(freeId, timerId);
    } while (!nextFreeTimerId.testAndSetRelease(freeId, newTimerId));
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:15,代码来源:qabstracteventdispatcher.cpp

示例2: releaseTimerId

// Releasing a timer ID requires putting the current ID back in the vector;
// we do it by setting:
//    X[timerId] = nextFreeTimerId;
// then we update nextFreeTimerId to the timer we've just released
//
// The extra code in allocateTimerId and releaseTimerId are ABA prevention
// and bucket memory. The buckets are simply to make sure we allocate only
// the necessary number of timers. See above.
//
// ABA prevention simply adds a value to 7 of the top 8 bits when resetting
// nextFreeTimerId.
void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId)
{
    int which = timerId & TimerIdMask;
    int bucket = bucketOffset(which);
    int at = bucketIndex(bucket, which);
    int *b = timerIds[bucket];

    Q_ASSERT_X(timerId == -b[at], "QAbstractEventDispatcher::releaseTimerId",
               "Internal error: timer ID not found");

    int freeId, newTimerId;
    do {
        freeId = nextFreeTimerId;//.loadAcquire(); // ### FIXME Proper memory ordering semantics
        b[at] = freeId & TimerIdMask;

        newTimerId = prepareNewValueWithSerialNumber(freeId, timerId);
    } while (!nextFreeTimerId.testAndSetRelease(freeId, newTimerId));
}
开发者ID:tsuibin,项目名称:emscripten-qt,代码行数:29,代码来源:qabstracteventdispatcher.cpp


注:本文中的QBasicAtomicInt::testAndSetRelease方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。