本文整理汇总了C++中Db::sync方法的典型用法代码示例。如果您正苦于以下问题:C++ Db::sync方法的具体用法?C++ Db::sync怎么用?C++ Db::sync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db::sync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cacheFlush
//.........这里部分代码省略.........
mph->setSubj(h->m_subj.left(index).simplified());
mph->setFrom(h->m_from);
mph->setStatus(MultiPartHeader::bh_new);
mph->setKey(++mPHKey);
//qDebug() << "Created mph with key " << mPHKey;
if (h->m_date.isNull())
qDebug() << "Date is null!!!";
else
mph->setPostingDate(createDateTime(h->m_date.split(" ")));
mph->setDownloadDate(QDateTime::currentDateTime().toTime_t());
mph->setNumParts(capTotal); // Also sets missing parts to capTotal
mph->addPart(pdb, capPart, h, hostId);
cache.insert(cIndex, mph);
ng->setHeadersNeedGrouping(true);
}
}
Q_DELETE(h);
}
// Multiple threads are still controlled by mutex at this point
ng->servLocalParts[hostId] += size;
qDebug() << "Server " << hostId << ", total articles = " << ng->totalArticles << ", adding " << groupArticles;
ng->totalArticles += groupArticles;
ng->unreadArticles += unreadArticles;
qDebug() << "Server " << hostId << ", total articles = " << ng->totalArticles;
ng->setMultiPartSequence(mPHKey);
groupArticles = 0;
unreadArticles = 0;
// sync the parts db
pdb->sync(0);
//Flush the cache that we've just built
QHash<QString, HeaderBase*>::iterator it = cache.begin();
QByteArray ba;
const char *cIndexCharArr = 0;
while (it != cache.end())
{
cIndex = it.key();
hb = (HeaderBase*)(it.value());
if (hb->getHeaderType() == 'm')
{
mph = (MultiPartHeader*)(it.value());
data.set_data(mph->data());
data.set_size(mph->getRecordSize());
//qDebug() << "Just saved mph with key " << mph->multiPartKey;
}
else
{
sph = (SinglePartHeader*)(it.value());
data.set_data(sph->data());
data.set_size(sph->getRecordSize());
}
ba = cIndex.toLocal8Bit();
cIndexCharArr = ba.constData();
key.set_data((void*) cIndexCharArr);
key.set_size(cIndex.length());
ret = db->put(NULL, &key, &data, 0);
if (ret != 0)
{
qDebug() << "Error flushing cache: " << ret;
// errorString=g_dbenv->strerror(ret);
errorString = "Failure whilst writing header record to database";
return false;
}
void *ptr = data.get_data();
Q_FREE(ptr);
if (hb->getHeaderType() == 'm')
{
Q_DELETE(mph);
}
else
{
Q_DELETE(sph);
}
++it;
}
locker.unlock(); // *************** this is a massive hold ***********************
cache.clear();
qDebug() << "Ok, cache flushed";
cacheFlushed = true;
return true;
}