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


C++ QBasicAtomicInt::fetchAndAddAcquire方法代码示例

本文整理汇总了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;
}
开发者ID:emmanuel099,项目名称:kio,代码行数:47,代码来源:connectionbackend.cpp


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