Follow ndn::Scheduler API changes
And some code cleanups
Refs: #4883
Change-Id: Ifca73d336579211cf137fd6afe905fb562291800
diff --git a/examples/full-sync.cpp b/examples/full-sync.cpp
index 09f7b5b..f92149d 100644
--- a/examples/full-sync.cpp
+++ b/examples/full-sync.cpp
@@ -19,8 +19,10 @@
#include <PSync/full-producer.hpp>
+#include <ndn-cxx/face.hpp>
#include <ndn-cxx/util/logger.hpp>
#include <ndn-cxx/util/random.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
#include <iostream>
@@ -52,13 +54,9 @@
// Add user prefixes and schedule updates for them in specified interval
for (int i = 0; i < m_numDataStreams; i++) {
ndn::Name prefix(userPrefix + "-" + ndn::to_string(i));
-
m_fullProducer.addUserNode(prefix);
-
- m_scheduler.scheduleEvent(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
- [this, prefix] {
- doUpdate(prefix);
- });
+ m_scheduler.schedule(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
+ [this, prefix] { doUpdate(prefix); });
}
}
@@ -78,10 +76,8 @@
NDN_LOG_INFO("Publish: " << prefix << "/" << seqNo);
if (seqNo < m_maxNumPublish) {
- m_scheduler.scheduleEvent(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
- [this, prefix] {
- doUpdate(prefix);
- });
+ m_scheduler.schedule(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
+ [this, prefix] { doUpdate(prefix); });
}
}
@@ -97,7 +93,7 @@
private:
ndn::Face m_face;
- ndn::util::Scheduler m_scheduler;
+ ndn::Scheduler m_scheduler;
psync::FullProducer m_fullProducer;
diff --git a/examples/producer.cpp b/examples/producer.cpp
index ef0ff2d..6fcbb25 100644
--- a/examples/producer.cpp
+++ b/examples/producer.cpp
@@ -19,8 +19,10 @@
#include <PSync/partial-producer.hpp>
+#include <ndn-cxx/face.hpp>
#include <ndn-cxx/util/logger.hpp>
#include <ndn-cxx/util/random.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
#include <iostream>
@@ -52,10 +54,8 @@
m_producer.addUserNode(updateName);
// Each user prefix is updated at random interval between 0 and 60 second
- m_scheduler.scheduleEvent(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
- [this, updateName] {
- doUpdate(updateName);
- });
+ m_scheduler.schedule(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
+ [this, updateName] { doUpdate(updateName); });
}
}
@@ -77,16 +77,14 @@
if (seqNo < m_maxNumPublish) {
// Schedule the next update for this user prefix b/w 0 and 60 seconds
- m_scheduler.scheduleEvent(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
- [this, updateName] {
- doUpdate(updateName);
- });
+ m_scheduler.schedule(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
+ [this, updateName] { doUpdate(updateName); });
}
}
private:
ndn::Face m_face;
- ndn::util::Scheduler m_scheduler;
+ ndn::Scheduler m_scheduler;
psync::PartialProducer m_producer;
@@ -114,4 +112,4 @@
catch (const std::exception& e) {
NDN_LOG_ERROR(e.what());
}
-}
\ No newline at end of file
+}