Merge remote-tracking branch 'git.irl/master'
diff --git a/src/dispatcher.cc b/src/dispatcher.cc
index 02ae150..33dd166 100644
--- a/src/dispatcher.cc
+++ b/src/dispatcher.cc
@@ -33,7 +33,7 @@
INIT_LOGGER ("Dispatcher");
static const string BROADCAST_DOMAIN = "/ndn/broadcast/chronoshare";
-const static double DEFAULT_SYNC_INTEREST_INTERVAL = 20.0;
+const static double DEFAULT_SYNC_INTEREST_INTERVAL = 2.0;
Dispatcher::Dispatcher(const std::string &localUserName
, const std::string &sharedFolder
diff --git a/src/sync-core.cc b/src/sync-core.cc
index e113b24..c6c0c24 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -23,7 +23,8 @@
#include "sync-state-helper.h"
#include "logging.h"
#include "random-interval-generator.h"
-#include "one-time-task.h"
+#include "simple-interval-generator.h"
+#include "periodic-task.h"
#include <boost/lexical_cast.hpp>
#include <boost/make_shared.hpp>
@@ -56,7 +57,7 @@
m_scheduler->start();
string tag = userName.toString() + "send-sync-interest";
double interval = (m_syncInterestInterval > 0 && m_syncInterestInterval < 30.0) ? m_syncInterestInterval : 4.0;
- m_sendSyncInterestTask = make_shared<OneTimeTask>(bind(&SyncCore::sendSyncInterest, this), tag, m_scheduler, interval);
+ m_sendSyncInterestTask = make_shared<PeriodicTask>(bind(&SyncCore::sendSyncInterest, this), tag, m_scheduler, make_shared<SimpleIntervalGenerator>(interval));
sendSyncInterest();
}
diff --git a/test/test-event-scheduler.cc b/test/test-event-scheduler.cc
index 4db9a0e..0d70abf 100644
--- a/test/test-event-scheduler.cc
+++ b/test/test-event-scheduler.cc
@@ -26,6 +26,7 @@
#include "random-interval-generator.h"
#include <boost/test/unit_test.hpp>
+#include <boost/make_shared.hpp>
#include <map>
#include <unistd.h>
@@ -136,6 +137,26 @@
scheduler->shutdown();
}
+void reschedule();
+SchedulerPtr schd0(new Scheduler());
+int resCount;
+TaskPtr task0(new PeriodicTask(boost::bind(reschedule), "testtest", schd0, boost::make_shared<SimpleIntervalGenerator>(0.5)));
+void reschedule()
+{
+ schd0->rescheduleTask(task0);
+ resCount++;
+}
+
+BOOST_AUTO_TEST_CASE(RescheduleTest)
+{
+ resCount = 0;
+ schd0->start();
+ schd0->addTask(task0);
+ usleep(5100000);
+ BOOST_CHECK_EQUAL(resCount, 10);
+ schd0->shutdown();
+}
+
BOOST_AUTO_TEST_CASE(GeneratorTest)
{
double interval = 10;