本文整理汇总了C++中QBasicAtomicInt::deref方法的典型用法代码示例。如果您正苦于以下问题:C++ QBasicAtomicInt::deref方法的具体用法?C++ QBasicAtomicInt::deref怎么用?C++ QBasicAtomicInt::deref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBasicAtomicInt
的用法示例。
在下文中一共展示了QBasicAtomicInt::deref方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void run()
{
while (t.elapsed() < one_minute) {
mutex.lock();
if (sentinel.ref()) ++errorCount;
if (!sentinel.deref()) ++errorCount;
lockCount.ref();
mutex.unlock();
if (mutex.tryLock()) {
if (sentinel.ref()) ++errorCount;
if (!sentinel.deref()) ++errorCount;
lockCount.ref();
mutex.unlock();
}
}
}
示例2: run
void run()
{
while (t.elapsed() < one_minute) {
mutex.lock();
Q_ASSERT(!sentinel.ref());
Q_ASSERT(sentinel.deref());
lockCount.ref();
mutex.unlock();
if (mutex.tryLock()) {
Q_ASSERT(!sentinel.ref());
Q_ASSERT(sentinel.deref());
lockCount.ref();
mutex.unlock();
}
}
}
示例3: messageHandler
static void messageHandler(QtMsgType type, const QMessageLogContext & context, const QString &message)
{
static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(QTest::maxWarnings);
if (QTest::TestLoggers::loggerCount() == 0) {
// if this goes wrong, something is seriously broken.
qInstallMessageHandler(oldMessageHandler);
QTEST_ASSERT(QTest::TestLoggers::loggerCount() != 0);
}
if (handleIgnoredMessage(type, message))
// the message is expected, so just swallow it.
return;
QString msg = qFormatLogMessage(type, context, message);
if (type != QtFatalMsg) {
if (counter.load() <= 0)
return;
if (!counter.deref()) {
QTest::TestLoggers::addMessage(QAbstractTestLogger::QSystem,
QStringLiteral("Maximum amount of warnings exceeded. Use -maxwarnings to override."));
return;
}
}
switch (type) {
case QtDebugMsg:
QTest::TestLoggers::addMessage(QAbstractTestLogger::QDebug, msg);
break;
case QtCriticalMsg:
QTest::TestLoggers::addMessage(QAbstractTestLogger::QSystem, msg);
break;
case QtWarningMsg:
QTest::TestLoggers::addMessage(QAbstractTestLogger::QWarning, msg);
break;
case QtFatalMsg:
QTest::TestLoggers::addMessage(QAbstractTestLogger::QFatal, msg);
/* Right now, we're inside the custom message handler and we're
* being qt_message_output in qglobal.cpp. After we return from
* this function, it will proceed with calling exit() and abort()
* and hence crash. Therefore, we call these logging functions such
* that we wrap up nicely, and in particular produce well-formed XML. */
QTestResult::addFailure("Received a fatal error.", "Unknown file", 0);
QTestLog::leaveTestFunction();
QTestLog::stopLogging();
break;
}
}
示例4:
inline ~SPointer() { count.deref(); }