本文整理汇总了C++中QBasicAtomicInt::fetchAndAddAcquire方法的典型用法代码示例。如果您正苦于以下问题:C++ QBasicAtomicInt::fetchAndAddAcquire方法的具体用法?C++ QBasicAtomicInt::fetchAndAddAcquire怎么用?C++ QBasicAtomicInt::fetchAndAddAcquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBasicAtomicInt
的用法示例。
在下文中一共展示了QBasicAtomicInt::fetchAndAddAcquire方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listenForRemote
bool ConnectionBackend::listenForRemote()
{
Q_ASSERT(state == Idle);
Q_ASSERT(!socket);
Q_ASSERT(!localServer); // !tcpServer as well
if (mode == LocalSocketMode) {
const QString prefix = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
static QBasicAtomicInt s_socketCounter = Q_BASIC_ATOMIC_INITIALIZER(1);
QTemporaryFile socketfile(prefix + QLatin1Char('/') + QCoreApplication::instance()->applicationName() + QStringLiteral("XXXXXX.%1.slave-socket").arg(s_socketCounter.fetchAndAddAcquire(1)));
if (!socketfile.open()) {
errorString = i18n("Unable to create io-slave: %1", strerror(errno));
return false;
}
QString sockname = socketfile.fileName();
address.clear();
address.setScheme(QStringLiteral("local"));
address.setPath(sockname);
socketfile.remove(); // can't bind if there is such a file
localServer = new KLocalSocketServer(this);
if (!localServer->listen(sockname, KLocalSocket::UnixSocket)) {
errorString = localServer->errorString();
delete localServer;
localServer = 0;
return false;
}
connect(localServer, SIGNAL(newConnection()), SIGNAL(newConnection()));
} else {
tcpServer = new QTcpServer(this);
tcpServer->listen(QHostAddress::LocalHost);
if (!tcpServer->isListening()) {
errorString = tcpServer->errorString();
delete tcpServer;
tcpServer = 0;
return false;
}
address = QUrl("tcp://127.0.0.1:" + QString::number(tcpServer->serverPort()));
connect(tcpServer, SIGNAL(newConnection()), SIGNAL(newConnection()));
}
state = Listening;
return true;
}