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


C++ NetworkManager::broadcast方法代码示例

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


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

示例1: fileExists

void Resources::fileExists(const string &path, map<InstanceID, bool> &instancesMap, const shared_ptr<Query> &query)
{
    LOG4CXX_TRACE(logger, "Resources::fileExists. Checking file '" << path << "'");
    NetworkManager* networkManager = NetworkManager::getInstance();

    FileExistsResourcesCollector* collector = new FileExistsResourcesCollector();
    uint64_t id = 0;
    {
        ScopedMutexLock lock(_lock);
        id = ++_lastResourceCollectorId;
        _resourcesCollectors[id] = collector;

        collector->collect(query->getInstanceID(), checkFileExists(path), false);
    }

    shared_ptr<MessageDesc> msg = make_shared<MessageDesc>(mtResourcesFileExistsRequest);
    shared_ptr<scidb_msg::ResourcesFileExistsRequest> request =
        msg->getRecord<scidb_msg::ResourcesFileExistsRequest>();
    msg->setQueryID(0);
    request->set_resource_request_id(id);
    request->set_file_path(path);
    networkManager->broadcast(msg);

    LOG4CXX_TRACE(logger, "Resources::fileExists. Waiting while instances return result for collector " << id);

    try
    {
       Semaphore::ErrorChecker errorChecker = bind(&Query::validateQueryPtr, query);
       collector->_collectorSem.enter(query->getInstancesCount() - 1, errorChecker);
    }
    catch (...)
    {
        LOG4CXX_TRACE(logger, "Resources::fileExists. Waiting for result of collector " << id <<
            " interrupter by error");
        {
            ScopedMutexLock lock(_lock);
            delete _resourcesCollectors[id];
            _resourcesCollectors.erase(id);
        }
        throw;
    }

    LOG4CXX_TRACE(logger, "Resources::fileExists. Returning result of collector " << id);

    {
        ScopedMutexLock lock(_lock);
        instancesMap = ((FileExistsResourcesCollector*) _resourcesCollectors[id])->_instancesMap;
        delete _resourcesCollectors[id];
        _resourcesCollectors.erase(id);
    }
}
开发者ID:tshead,项目名称:scidb-osx-12.3-snow-leopard,代码行数:51,代码来源:Resources.cpp


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