本文整理汇总了C++中SharedVariant::isUnserializedObj方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedVariant::isUnserializedObj方法的具体用法?C++ SharedVariant::isUnserializedObj怎么用?C++ SharedVariant::isUnserializedObj使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedVariant
的用法示例。
在下文中一共展示了SharedVariant::isUnserializedObj方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handlePromoteObj
bool ConcurrentTableSharedStore::handlePromoteObj(CStrRef key,
SharedVariant* svar,
CVarRef value) {
SharedVariant *converted = svar->convertObj(value);
if (converted) {
Map::accessor acc;
if (!m_vars.find(acc, key.data())) {
// There is a chance another thread deletes the key when this thread is
// converting the object. In that case, we just bail
converted->decRef();
return false;
}
// A write lock was acquired during find
StoreValue *sval = &acc->second;
SharedVariant *sv = sval->var;
// sv may not be same as svar here because some other thread may have
// updated it already, check before updating
if (sv == svar && !sv->isUnserializedObj()) {
int64 ttl = sval->expiry ? sval->expiry - time(NULL) : 0;
stats_on_update(key.get(), sval, converted, ttl);
sval->var = converted;
sv->decRef();
return true;
}
converted->decRef();
}
return false;
}
示例2: get
bool ConcurrentTableSharedStore::get(CStrRef key, Variant &value) {
bool stats = RuntimeOption::EnableStats && RuntimeOption::EnableAPCStats;
bool statsFetch = RuntimeOption::EnableAPCSizeStats &&
RuntimeOption::EnableAPCFetchStats;
const StoreValue *val;
SharedVariant *svar = NULL;
ReadLock l(m_lock);
bool expired = false;
{
Map::const_accessor acc;
if (!m_vars.find(acc, key.data())) {
if (stats) ServerStats::Log("apc.miss", 1);
return false;
} else {
val = &acc->second;
if (val->expired()) {
// Because it only has a read lock on the data, deletion from
// expiration has to happen after the lock is released
expired = true;
} else {
svar = val->var;
if (RuntimeOption::ApcAllowObj) {
// Hold ref here
svar->incRef();
}
value = svar->toLocal();
if (statsFetch) {
SharedStoreStats::onGet(key.get(), svar);
}
}
}
}
if (expired) {
if (stats) {
ServerStats::Log("apc.miss", 1);
}
eraseImpl(key, true);
return false;
}
if (stats) {
ServerStats::Log("apc.hit", 1);
}
if (RuntimeOption::ApcAllowObj) {
bool statsDetail = RuntimeOption::EnableAPCSizeStats &&
RuntimeOption::EnableAPCSizeGroup;
SharedVariant *converted = svar->convertObj(value);
if (converted) {
Map::accessor acc;
m_vars.find(acc, key.data()); // start a write lock
StoreValue *sval = &acc->second;
SharedVariant *sv = sval->var;
// sv may not be same as svar here because some other thread may have
// updated it already, check before updating
if (!sv->isUnserializedObj()) {
if (statsDetail) {
SharedStoreStats::onDelete(key.get(), sv, true);
}
sval->var = converted;
sv->decRef();
if (RuntimeOption::EnableAPCSizeStats) {
int32 newSize = converted->getSpaceUsage();
SharedStoreStats::updateDirect(sval->size, newSize);
sval->size = newSize;
}
if (statsDetail) {
int64 ttl = sval->expiry ? sval->expiry - time(NULL) : 0;
SharedStoreStats::onStore(key.get(), converted, ttl, false);
}
} else {
converted->decRef();
}
}
// release the extra ref
svar->decRef();
}
return true;
}