本文整理汇总了C++中DataObjectRef::getReceiveOrCreateTime方法的典型用法代码示例。如果您正苦于以下问题:C++ DataObjectRef::getReceiveOrCreateTime方法的具体用法?C++ DataObjectRef::getReceiveOrCreateTime怎么用?C++ DataObjectRef::getReceiveOrCreateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectRef
的用法示例。
在下文中一共展示了DataObjectRef::getReceiveOrCreateTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializationCallback
void initializationCallback(Event *e)
{
DataObjectRefList dObjs = e->getDataObjectList();
for (DataObjectRefList::iterator it = dObjs.begin(); it != dObjs.end(); it++) {
DataObjectRef dObj = *it;
if (!purger->isResponsibleForDataObject(dObj)) {
continue;
}
double now = (Timeval::now()).getTimeAsSecondsDouble();
double then = (dObj->getReceiveOrCreateTime()).getTimeAsSecondsDouble();
const Attribute *attr = dObj->getAttribute(purger->getMetricField(), "*", 1);
double ttl = atof(attr->getValue().c_str());
if (now < (then + ttl + purger->getMinDBTimeS())) {
purger->schedulePurge(dObj);
}
else {
kernel->getDataStore()->deleteDataObject(dObj, purger->getKeepInBloomfilter());
}
}
}
示例2: atof
void
CachePurgerRelTTL::schedulePurge(
DataObjectRef &dObj)
{
if (!isResponsibleForDataObject(dObj)) {
HAGGLE_ERR("Cannot schedule purge for DO not responsible for\n");
return;
}
const Attribute *attr = dObj->getAttribute(metricField, "*", 1);
if (!attr) {
HAGGLE_ERR("Attribute not specified\n");
return;
}
double now = (Timeval::now()).getTimeAsSecondsDouble();
double ttl = atof(attr->getValue().c_str());
double then = (dObj->getReceiveOrCreateTime()).getTimeAsSecondsDouble();
double expTime = ttl - (now - then);
expTime = expTime > minDBtimeS ? expTime : minDBtimeS;
getKernel()->addEvent(new Event(deleteCallback, dObj, expTime));
}