本文整理汇总了C++中Future::error方法的典型用法代码示例。如果您正苦于以下问题:C++ Future::error方法的具体用法?C++ Future::error怎么用?C++ Future::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Future
的用法示例。
在下文中一共展示了Future::error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _read
void _read(const Pipe::Reader& reader, const Future<Result<Event>>& event)
{
CHECK(!event.isDiscarded());
// Ignore enqueued events from the previous Subscribe call reader.
if (subscribed.isNone() || subscribed->reader != reader) {
VLOG(1) << "Ignoring event from old stale connection";
return;
}
CHECK_EQ(SUBSCRIBED, state);
CHECK_SOME(connectionId);
// This could happen if the agent process died while sending a response.
if (event.isFailed()) {
LOG(ERROR) << "Failed to decode the stream of events: "
<< event.failure();
disconnected(connectionId.get(), event.failure());
return;
}
// This could happen if the agent failed over after sending an event.
if (event->isNone()) {
const string error = "End-Of-File received from agent. The agent closed "
"the event stream";
LOG(ERROR) << error;
disconnected(connectionId.get(), error);
return;
}
if (event->isError()) {
error("Failed to de-serialize event: " + event->error());
return;
}
receive(event.get().get(), false);
read();
}
示例2: addSdSocketToCache
void SessionPrivate::addSdSocketToCache(Future<void> f, const qi::Url& url,
qi::Promise<void> p)
{
qiLogDebug() << "addSocketToCache processing";
if (f.hasError())
{
qiLogDebug() << "addSdSocketToCache: connect reported failure";
_serviceHandler.removeService("ServiceDirectory");
p.setError(f.error());
return;
}
// Allow the SD process to use the existing socket to talk to our services
_serverObject.registerSocket(_sdClient.socket());
/* Allow reusing the SD socket for communicating with services.
* To do this, we must add it to our socket cache, and for this we need
* to know the sd machineId
*/
std::string mid;
try
{
mid = _sdClient.machineId();
}
catch (const std::exception& e)
{ // Provide a nice message for backward compatibility
qiLogVerbose() << e.what();
qiLogWarning() << "Failed to obtain machineId, connection to service directory will not be reused for other services.";
p.setValue(0);
return;
}
TransportSocketPtr s = _sdClient.socket();
qiLogVerbose() << "Inserting sd to cache for " << mid <<" " << url.str() << std::endl;
_socketsCache.insert(mid, s->remoteEndpoint(), s);
p.setValue(0);
}