本文整理汇总了C++中Persist函数的典型用法代码示例。如果您正苦于以下问题:C++ Persist函数的具体用法?C++ Persist怎么用?C++ Persist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Persist函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: WaitForPreload
nsresult
DOMStorageCache::RemoveItem(const DOMStorage* aStorage, const nsAString& aKey,
nsString& aOld)
{
Telemetry::AutoTimer<Telemetry::LOCALDOMSTORAGE_REMOVEKEY_MS> autoTimer;
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_REMOVEKEY_BLOCKING_MS);
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
}
Data& data = DataSet(aStorage);
if (!data.mKeys.Get(aKey, &aOld)) {
SetDOMStringToNull(aOld);
return NS_SUCCESS_DOM_NO_OPERATION;
}
// Recalculate the cached data size
const int64_t delta = -(static_cast<int64_t>(aOld.Length()));
unused << ProcessUsageDelta(aStorage, delta);
data.mKeys.Remove(aKey);
if (Persist(aStorage)) {
return sDatabase->AsyncRemoveItem(this, aKey);
}
return NS_OK;
}
开发者ID:BrunoReX,项目名称:palemoon,代码行数:30,代码来源:DOMStorageCache.cpp
示例2: WaitForPreload
nsresult
DOMStorageCache::RemoveItem(const DOMStorage* aStorage, const nsAString& aKey,
nsString& aOld)
{
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_REMOVEKEY_BLOCKING_MS);
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
}
Data& data = DataSet(aStorage);
if (!data.mKeys.Get(aKey, &aOld)) {
SetDOMStringToNull(aOld);
return NS_SUCCESS_DOM_NO_OPERATION;
}
// Recalculate the cached data size
const int64_t delta = -(static_cast<int64_t>(aOld.Length()) +
static_cast<int64_t>(aKey.Length()));
Unused << ProcessUsageDelta(aStorage, delta);
data.mKeys.Remove(aKey);
if (Persist(aStorage)) {
if (!sDatabase) {
NS_ERROR("Writing to localStorage after the database has been shut down"
", data lose!");
return NS_ERROR_NOT_INITIALIZED;
}
return sDatabase->AsyncRemoveItem(this, aKey);
}
return NS_OK;
}
开发者ID:flodolo,项目名称:gecko-dev,代码行数:35,代码来源:DOMStorageCache.cpp
示例3: WaitForPreload
nsresult
LocalStorageCache::SetItem(const LocalStorage* aStorage, const nsAString& aKey,
const nsString& aValue, nsString& aOld,
const MutationSource aSource)
{
// Size of the cache that will change after this action.
int64_t delta = 0;
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_SETVALUE_BLOCKING_MS);
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
}
Data& data = DataSet(aStorage);
if (!data.mKeys.Get(aKey, &aOld)) {
SetDOMStringToNull(aOld);
// We only consider key size if the key doesn't exist before.
delta += static_cast<int64_t>(aKey.Length());
}
delta += static_cast<int64_t>(aValue.Length()) -
static_cast<int64_t>(aOld.Length());
if (!ProcessUsageDelta(aStorage, delta, aSource)) {
return NS_ERROR_DOM_QUOTA_REACHED;
}
if (aValue == aOld && DOMStringIsNull(aValue) == DOMStringIsNull(aOld)) {
return NS_SUCCESS_DOM_NO_OPERATION;
}
data.mKeys.Put(aKey, aValue);
if (aSource == ContentMutation && Persist(aStorage)) {
if (!sDatabase) {
NS_ERROR("Writing to localStorage after the database has been shut down"
", data lose!");
return NS_ERROR_NOT_INITIALIZED;
}
if (DOMStringIsNull(aOld)) {
return sDatabase->AsyncAddItem(this, aKey, aValue);
}
return sDatabase->AsyncUpdateItem(this, aKey, aValue);
}
return NS_OK;
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:52,代码来源:LocalStorageCache.cpp
示例4: Persist
/** (Re)initialize for on-demand loading
*
* Calling Rollback will cancel all uncommitted changes.
*/
bool c4_Storage::Rollback(bool full_) {
c4_Persist *pers = Persist();
bool f = Strategy().IsValid() && pers->Rollback(full_);
// adjust our copy when the root view has been replaced
*(c4_View*)this = &pers->Root();
return f;
}
开发者ID:aosm,项目名称:tcl,代码行数:11,代码来源:store.cpp
示例5: Persist
/**
* Save size (& optionally position) in registry
*/
void
CMoveConstraint::LoadPosition(LPCTSTR szValueName, bool position)
{
m_sRegistryValueName = szValueName;
m_bPersistent=true;
Persist(false, position);
}
开发者ID:Kirozen,项目名称:winmerge-v2,代码行数:10,代码来源:CMoveConstraint.cpp
示例6: Initialize
c4_Storage::c4_Storage(const char *fname_, int mode_) {
c4_FileStrategy *strat = d4_new c4_FileStrategy;
strat->DataOpen(fname_, mode_);
Initialize(*strat, true, mode_);
if (strat->IsValid())
Persist()->LoadAll();
}
开发者ID:aosm,项目名称:tcl,代码行数:8,代码来源:store.cpp
示例7: CreateFile
void SimpleCheckpoint::DoCheckpoint() {
// TODO split checkpoint file into multiple files in the future
// Create a new file for checkpoint
CreateFile();
auto &log_manager = LogManager::GetInstance();
if (logger_ == nullptr) {
logger_.reset(BackendLogger::GetBackendLogger(LOGGING_TYPE_NVM_WAL));
}
start_commit_id_ = log_manager.GetGlobalMaxFlushedCommitId();
if (start_commit_id_ == INVALID_CID) {
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
start_commit_id_ = txn_manager.GetMaxCommittedCid();
}
LOG_TRACE("DoCheckpoint cid = %lu", start_commit_id_);
// Add txn begin record
std::shared_ptr<LogRecord> begin_record(new TransactionRecord(
LOGRECORD_TYPE_TRANSACTION_BEGIN, start_commit_id_));
CopySerializeOutput begin_output_buffer;
begin_record->Serialize(begin_output_buffer);
records_.push_back(begin_record);
auto &catalog_manager = catalog::Manager::GetInstance();
auto database_count = catalog_manager.GetDatabaseCount();
// loop all databases
for (oid_t database_idx = 0; database_idx < database_count; database_idx++) {
auto database = catalog_manager.GetDatabase(database_idx);
auto table_count = database->GetTableCount();
auto database_oid = database->GetOid();
// loop all tables
for (oid_t table_idx = 0; table_idx < table_count; table_idx++) {
// Get the target table
storage::DataTable *target_table = database->GetTable(table_idx);
PL_ASSERT(target_table);
LOG_TRACE("SeqScan: database idx %u table idx %u: %s", database_idx,
table_idx, target_table->GetName().c_str());
Scan(target_table, database_oid);
}
}
// Add txn commit record
std::shared_ptr<LogRecord> commit_record(new TransactionRecord(
LOGRECORD_TYPE_TRANSACTION_COMMIT, start_commit_id_));
CopySerializeOutput commit_output_buffer;
commit_record->Serialize(commit_output_buffer);
records_.push_back(commit_record);
// TODO Add delimiter record for checkpoint recovery as well
Persist();
Cleanup();
most_recent_checkpoint_cid = start_commit_id_;
}
开发者ID:aelroby,项目名称:peloton,代码行数:58,代码来源:simple_checkpoint.cpp
示例8: WaitForPreload
nsresult
DOMStorageCache::SetItem(const DOMStorage* aStorage, const nsAString& aKey,
const nsString& aValue, nsString& aOld)
{
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_SETVALUE_BLOCKING_MS);
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
}
Data& data = DataSet(aStorage);
if (!data.mKeys.Get(aKey, &aOld)) {
SetDOMStringToNull(aOld);
}
// Check the quota first
const int64_t delta = static_cast<int64_t>(aValue.Length()) -
static_cast<int64_t>(aOld.Length());
if (!ProcessUsageDelta(aStorage, delta)) {
return NS_ERROR_DOM_QUOTA_REACHED;
}
if (aValue == aOld && DOMStringIsNull(aValue) == DOMStringIsNull(aOld)) {
return NS_SUCCESS_DOM_NO_OPERATION;
}
data.mKeys.Put(aKey, aValue);
if (Persist(aStorage)) {
if (!sDatabase) {
NS_ERROR("Writing to localStorage after the database has been shut down"
", data lose!");
return NS_ERROR_NOT_INITIALIZED;
}
if (DOMStringIsNull(aOld)) {
return sDatabase->AsyncAddItem(this, aKey, aValue);
}
return sDatabase->AsyncUpdateItem(this, aKey, aValue);
}
return NS_OK;
}
开发者ID:Acidburn0zzz,项目名称:tor-browser,代码行数:45,代码来源:DOMStorageCache.cpp
示例9: lock
bool CFavouritesService::Save(const CFileItemList& items)
{
{
CSingleLock lock(m_criticalSection);
m_favourites.Clear();
m_favourites.Copy(items);
Persist();
}
OnUpdated();
return true;
}
开发者ID:anaconda,项目名称:xbmc,代码行数:11,代码来源:FavouritesService.cpp
示例10: Persist
bool CPVREpg::Update(const CEpg &epg, bool bUpdateDb /* = false */)
{
bool bReturn = CEpg::Update(epg, false); // don't update the db yet
m_Channel = epg.m_Channel;
m_bHasChannel = true;
if (bUpdateDb)
bReturn = Persist(false);
return bReturn;
}
开发者ID:vanegithub,项目名称:xbmc,代码行数:12,代码来源:PVREpg.cpp
示例11: PersistBank
HRESULT CACTController::PersistBank(IStream* pStm, bool bSave, int iBank)
{
// Rotaries binding
if (FAILED(Persist(pStm, bSave, &m_dwKnobsBinding[iBank], sizeof(m_dwKnobsBinding[iBank]))))
return E_FAIL;
// Exclude rotaries from ACT
if (FAILED(Persist(pStm, bSave, &m_bExcludeRotariesACT[iBank], sizeof(m_bExcludeRotariesACT[iBank]))))
return E_FAIL;
// Sliders binding
if (FAILED(Persist(pStm, bSave, &m_dwSlidersBinding[iBank], sizeof(m_dwSlidersBinding[iBank]))))
return E_FAIL;
// Exclude sliders from ACT
if (FAILED(Persist(pStm, bSave, &m_bExcludeSlidersACT[iBank], sizeof(m_bExcludeSlidersACT[iBank]))))
return E_FAIL;
// Buttons
for (int n = 0; n < NUM_VIRTUAL_BUTTONS; n++)
{
if (FAILED(Persist(pStm, bSave, &m_dwButtonAction[iBank][n], sizeof(m_dwButtonAction[iBank][n]))))
return E_FAIL;
if (FAILED(Persist(pStm, bSave, &m_bButtonExcludeACT[iBank][n], sizeof(m_bButtonExcludeACT[iBank][n]))))
return E_FAIL;
}
return S_OK;
}
开发者ID:docbradley,项目名称:Cakewalk-Control-Surface-SDK,代码行数:30,代码来源:ActControllerPersist.cpp
示例12: WaitForPreload
void
DOMStorageCache::GetKeys(const DOMStorage* aStorage, nsTArray<nsString>& aKeys)
{
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETALLKEYS_BLOCKING_MS);
}
if (NS_FAILED(mLoadResult)) {
return;
}
DataSet(aStorage).mKeys.EnumerateRead(KeysArrayBuilder, &aKeys);
}
开发者ID:Manishearth,项目名称:gecko-dev,代码行数:13,代码来源:DOMStorageCache.cpp
示例13: d4_assert
/// Define the complete view structure of the storage
void c4_Storage::SetStructure(const char *description_) {
d4_assert(description_ != 0);
if (description_ != Description()) {
c4_String s = "[" + c4_String(description_) + "]";
description_ = s;
c4_Field *field = d4_new c4_Field(description_);
d4_assert(! *description_);
d4_assert(field != 0);
Persist()->Root().Restructure(*field, false);
}
}
开发者ID:aosm,项目名称:tcl,代码行数:15,代码来源:store.cpp
示例14: Persist
HRESULT CACTController::Persist(IStream* pStm, bool bSave, CString *pStr)
{
int iLen;
if (bSave)
{
iLen = pStr->GetLength();
if (FAILED(Persist(pStm, bSave, &iLen, sizeof(iLen))))
return E_FAIL;
if (FAILED(Persist(pStm, bSave, (void *)(LPCTSTR)(*pStr), iLen)))
return E_FAIL;
}
else
{
if (FAILED(Persist(pStm, bSave, &iLen, sizeof(iLen))))
return E_FAIL;
HRESULT hr = Persist(pStm, bSave, pStr->GetBuffer(iLen), iLen);
pStr->ReleaseBuffer(iLen);
if (FAILED(hr))
return E_FAIL;
}
return S_OK;
}
开发者ID:docbradley,项目名称:Cakewalk-Control-Surface-SDK,代码行数:24,代码来源:ActControllerPersist.cpp
示例15:
Service& Service::operator=(const Service& s)
{
*reinterpret_cast<Persist *>(this) = Persist(s);
service_label = s.service_label;
service_descriptor = s.service_descriptor;
service_identifier = s.service_identifier;
country = s.country;
language = s.language;
language_long = s.language_long;
audio_ref = s.audio_ref;
data_ref = s.data_ref;
afs_ref = s.afs_ref;
conditional_access = s.conditional_access;
ca_system_identifier = s.ca_system_identifier;
ca_data = s.ca_data;
announcement = s.announcement;
return *this;
}
开发者ID:rafael2k,项目名称:drmcs,代码行数:18,代码来源:Service.cpp
示例16: data
nsresult
DOMStorageCache::GetKey(const DOMStorage* aStorage, uint32_t aIndex, nsAString& aRetval)
{
// XXX: This does a linear search for the key at index, which would
// suck if there's a large numer of indexes. Do we care? If so,
// maybe we need to have a lazily populated key array here or
// something?
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETKEY_BLOCKING_MS);
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
}
IndexFinderData data(aIndex, aRetval);
DataSet(aStorage).mKeys.EnumerateRead(FindKeyOrder, &data);
return NS_OK;
}
开发者ID:Manishearth,项目名称:gecko-dev,代码行数:18,代码来源:DOMStorageCache.cpp
示例17: random_hex_string
bool ReplBacklog::Load(const std::string& path, uint32 backlog_size)
{
if (0 != m_backlog.Init(path,
REPL_STATE_MAX_SIZE + backlog_size))
{
return false;
}
m_state = (ReplPersistState*) (m_backlog.m_buf);
m_state->repl_backlog_size = backlog_size;
m_repl_backlog = (m_backlog.m_buf + REPL_STATE_MAX_SIZE);
if (m_state->serverkey[0])
{
/*
* Loaded previous state, do nothing
*/
}
else
{
std::string randomkey = random_hex_string(SERVER_KEY_SIZE);
memcpy(m_state->serverkey, randomkey.data(), SERVER_KEY_SIZE);
m_state->serverkey[SERVER_KEY_SIZE] = 0;
m_state->repl_backlog_histlen = 0;
m_state->repl_backlog_idx = 0;
/* When a new backlog buffer is created, we increment the replication
* offset by one to make sure we'll not be able to PSYNC with any
* previous slave. This is needed because we avoid incrementing the
* master_repl_offset if no backlog exists nor slaves are attached. */
m_state->master_repl_offset++;
/* We don't have any data inside our buffer, but virtually the first
* byte we have is the next byte that will be generated for the
* replication stream. */
m_state->repl_backlog_off = m_state->master_repl_offset + 1;
m_state->cksm = 0;
m_state->current_db = ARDB_GLOBAL_DB;
m_sync_state_change = true;
Persist();
}
m_last_sync_offset = m_state->repl_backlog_off;
return true;
}
开发者ID:pandyxu,项目名称:ardb,代码行数:42,代码来源:repl_backlog.cpp
注:本文中的Persist函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论