本文整理汇总了C++中QCriticalSection::lock方法的典型用法代码示例。如果您正苦于以下问题:C++ QCriticalSection::lock方法的具体用法?C++ QCriticalSection::lock怎么用?C++ QCriticalSection::lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCriticalSection
的用法示例。
在下文中一共展示了QCriticalSection::lock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fetchAndAdd
int QAtomicInt::fetchAndAdd(int valueToAdd)
{
int returnValue;
qAtomicCriticalSection.lock();
returnValue = m_value;
m_value += valueToAdd;
qAtomicCriticalSection.unlock();
return returnValue;
}
示例2: QBasicAtomicInt_fetchAndAddOrdered
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
{
int returnValue;
qAtomicCriticalSection.lock();
returnValue = *_q_value;
*_q_value += valueToAdd;
qAtomicCriticalSection.unlock();
return returnValue;
}
示例3: QBasicAtomicInt_fetchAndStoreOrdered
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
{
int returnValue;
qAtomicCriticalSection.lock();
returnValue = *_q_value;
*_q_value = newValue;
qAtomicCriticalSection.unlock();
return returnValue;
}
示例4:
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
{
void *returnValue;
qAtomicCriticalSection.lock();
returnValue = *_q_value;
*_q_value = reinterpret_cast<char *>(returnValue) + valueToAdd;
qAtomicCriticalSection.unlock();
return returnValue;
}
示例5: QBasicAtomicInt_testAndSetOrdered
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
{
bool returnValue = false;
qAtomicCriticalSection.lock();
if (*_q_value == expectedValue) {
*_q_value = newValue;
returnValue = true;
}
qAtomicCriticalSection.unlock();
return returnValue;
}
示例6: testAndSet
bool QAtomicInt::testAndSet(int expectedValue,int newValue)
{
bool returnValue = false;
qAtomicCriticalSection.lock();
if (m_value == expectedValue)
{
m_value = newValue;
returnValue = true;
}
qAtomicCriticalSection.unlock();
return returnValue;
}