Delaying saving of the local state change from dispatcher (useful when many changes happen at about the same time)
Change-Id: I6082a335ce1f061ddcd53b7ce46f4edbab310fbe
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 4aaf1a5..f744f26 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -38,6 +38,8 @@
const std::string SYNC_INTEREST_TAG = "send-sync-interest";
const std::string SYNC_INTEREST_TAG2 = "send-sync-interest2";
+const std::string LOCAL_STATE_CHANGE_DELAYED_TAG = "local-state-changed";
+
using namespace boost;
using namespace Ccnx;
@@ -112,6 +114,15 @@
}
void
+SyncCore::localStateChangedDelayed ()
+{
+ // many calls to localStateChangedDelayed within 0.5 second will be suppressed to one localStateChanged calls
+ Scheduler::scheduleOneTimeTask (m_scheduler, 0.5,
+ bind (&SyncCore::localStateChanged, this),
+ LOCAL_STATE_CHANGE_DELAYED_TAG);
+}
+
+void
SyncCore::handleInterest(const Name &name)
{
int size = name.size();