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