MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / PersistProfiles

Function PersistProfiles

libi2pd/Profiling.cpp:312–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310 }
311
312 std::future<void> PersistProfiles ()
313 {
314 auto ts = i2p::util::GetSecondsSinceEpoch ();
315 std::list<std::pair<i2p::data::IdentHash, std::shared_ptr<RouterProfile> > > tmp;
316 {
317 std::lock_guard<std::mutex> l(g_ProfilesMutex);
318 for (auto it = g_Profiles.begin (); it != g_Profiles.end ();)
319 {
320 if (it->second->IsUpdated () && ts > it->second->GetLastPersistTime () + PEER_PROFILE_PERSIST_INTERVAL)
321 {
322 tmp.push_back (*it);
323 it->second->SetLastPersistTime (ts);
324 it->second->SetUpdated (false);
325 }
326 if (!it->second->IsUpdated () && ts > std::max (it->second->GetLastUpdateTime (), it->second->GetLastAccessTime ()) + PEER_PROFILE_PERSIST_INTERVAL)
327 it = g_Profiles.erase (it);
328 else
329 it++;
330 }
331 }
332 if (!tmp.empty ())
333 return std::async (std::launch::async, SaveProfilesToDisk, std::move (tmp));
334 return std::future<void>();
335 }
336
337 void SaveProfiles ()
338 {

Callers 1

RunMethod · 0.85

Calls 8

GetSecondsSinceEpochFunction · 0.85
GetLastPersistTimeMethod · 0.80
push_backMethod · 0.80
SetLastPersistTimeMethod · 0.80
GetLastAccessTimeMethod · 0.80
IsUpdatedMethod · 0.45
SetUpdatedMethod · 0.45
GetLastUpdateTimeMethod · 0.45

Tested by

no test coverage detected