本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}