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


C++ QAtomicInt::testAndSetOrdered方法代码示例

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


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

示例1: initialized

/*
  Cache all the path look-up in a singleton so it only has to be done once
  per process.  Previous implementations also did this, but lets make it
  thread-safe while we're on the job.
*/
QtopiaPathHelper *QtopiaPathHelper::instance()
{
    static QtopiaPathHelper ph;
    static QAtomicInt initialized(0);

    if ( initialized.testAndSetOrdered( 0, 1 ))
    {
        QChar sl = QDir::separator();
        const char *d = getenv("QTOPIA_PATH");
        if ( d ) {
            ph.installPaths = QString(d).split(":");
            for (QStringList::Iterator it=ph.installPaths.begin(); it!=ph.installPaths.end(); ++it) {
                if ( (*it)[(*it).length()-1] != sl )
                    (*it) += sl;
            }
        }

        // The installation directory is always searched before QTOPIA_PATH
        ph.prefixPath = QLibraryInfo::location(QLibraryInfo::PrefixPath);
        if ( ph.prefixPath[ph.prefixPath.length()-1] != sl )
            ph.prefixPath += sl;
        ph.installPaths.prepend(ph.prefixPath);

        // System update directory is always searched first
        ph.setUpdatePath();
        QString up = ph.updatePath;
        if ( !up.isEmpty() )
            ph.installPaths.prepend(up);

        // Package paths are last
        ph.setPackagePath();
        QString pp = ph.packagePath;
        if ( !pp.isEmpty() )
            ph.installPaths.append( pp );
        QDir::root().mkpath( pp + "/pics" );
        QDir::root().mkpath( pp + "/sounds" );

        initialized = 2;
    }
    else
    {
        while ( initialized != 2 )
            Qtopia::msleep( 5 );
    }

    return &ph;
}
开发者ID:GuoMarvin,项目名称:qtmoko,代码行数:52,代码来源:qtopianamespace.cpp

示例2: myMessageOutput

void myMessageOutput(QtMsgType type, const char *msg)
{
    QString strMsg = QString::fromLatin1(msg);

    if (!QCoreApplication::closingDown()) {
        if (!logger.isNull()) {
            if (recursiveLock.testAndSetOrdered(0, 1)) {
                QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
                recursiveLock = 0;
            }
        } else {
            warnings += strMsg;
            warnings += QLatin1Char('\n');
        }
    }
    if (systemMsgOutput) { // Windows
        systemMsgOutput(type, msg);
    } else { // Unix
        fprintf(stderr, "%s\n", msg);
        fflush(stderr);
    }
}
开发者ID:bakaiadam,项目名称:collaborative_qt_creator,代码行数:22,代码来源:main.cpp

示例3: myMessageOutput

void myMessageOutput(QtMsgType type, const char *msg)
{
    QString strMsg = QString::fromLatin1(msg);

    if (!QCoreApplication::closingDown()) {
        if (!logger.isNull()) {
            if (recursiveLock.testAndSetOrdered(0, 1)) {
                QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
                recursiveLock = 0;
            }
        } else {
            warnings += strMsg;
            warnings += QLatin1Char('\n');
        }
    }
#if defined (Q_OS_SYMBIAN)
    static int fd = -1;
    if (fd == -1)
        fd = ::open("E:\\qml.log", O_WRONLY | O_CREAT);

    ::write(fd, msg, strlen(msg));
    ::write(fd, "\n", 1);
    ::fsync(fd);
    switch (type) {
    case QtFatalMsg:
        abort();
    }
#endif

    if (systemMsgOutput) {
        systemMsgOutput(type, msg);
    } else { // Unix
        fprintf(stderr, "%s\n", msg);
        fflush(stderr);
    }
}
开发者ID:Suneal,项目名称:qt,代码行数:36,代码来源:main.cpp


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