本文整理汇总了C++中ControlParameters::getExpirationPeriod方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlParameters::getExpirationPeriod方法的具体用法?C++ ControlParameters::getExpirationPeriod怎么用?C++ ControlParameters::getExpirationPeriod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlParameters
的用法示例。
在下文中一共展示了ControlParameters::getExpirationPeriod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendResponse
void
RibManager::registerEntry(const shared_ptr<const Interest>& request,
ControlParameters& parameters)
{
ndn::nfd::RibRegisterCommand command;
if (!validateParameters(command, parameters)) {
NFD_LOG_DEBUG("register result: FAIL reason: malformed");
if (static_cast<bool>(request)) {
sendResponse(request->getName(), 400, "Malformed command");
}
return;
}
bool isSelfRegistration = (!parameters.hasFaceId() || parameters.getFaceId() == 0);
if (isSelfRegistration) {
shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = request->getTag<lp::IncomingFaceIdTag>();
if (incomingFaceIdTag == nullptr) {
sendResponse(request->getName(), 503,
"requested self-registration, but IncomingFaceId is unavailable");
return;
}
parameters.setFaceId(*incomingFaceIdTag);
}
// Respond since command is valid and authorized
sendSuccessResponse(request, parameters);
Route route;
route.faceId = parameters.getFaceId();
route.origin = parameters.getOrigin();
route.cost = parameters.getCost();
route.flags = parameters.getFlags();
if (parameters.hasExpirationPeriod() &&
parameters.getExpirationPeriod() != time::milliseconds::max())
{
route.expires = time::steady_clock::now() + parameters.getExpirationPeriod();
// Schedule a new event, the old one will be cancelled during rib insertion.
scheduler::EventId eventId = scheduler::schedule(parameters.getExpirationPeriod(),
bind(&Rib::onRouteExpiration, &m_managedRib, parameters.getName(), route));
NFD_LOG_TRACE("Scheduled unregistration at: " << route.expires <<
" with EventId: " << eventId);
// Set the NewEventId of this entry
route.setExpirationEvent(eventId);
}
else {
route.expires = time::steady_clock::TimePoint::max();
}
NFD_LOG_INFO("Adding route " << parameters.getName() << " nexthop=" << route.faceId
<< " origin=" << route.origin
<< " cost=" << route.cost);
RibUpdate update;
update.setAction(RibUpdate::REGISTER)
.setName(parameters.getName())
.setRoute(route);
m_managedRib.beginApplyUpdate(update,
bind(&RibManager::onRibUpdateSuccess, this, update),
bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));
m_registeredFaces.insert(route.faceId);
}