[ndnSIM] face: Emulation mode of ndn::Face
Change-Id: Ib345978575104afa436296d2f5a824a39e3a9780
diff --git a/src/detail/face-impl.hpp b/src/detail/face-impl.hpp
index ef49992..b2356c0 100644
--- a/src/detail/face-impl.hpp
+++ b/src/detail/face-impl.hpp
@@ -56,10 +56,9 @@
Impl(Face& face)
: m_face(face)
, m_scheduler(m_face.getIoService())
- , m_processEventsTimeoutEvent(m_scheduler)
{
auto postOnEmptyPitOrNoRegisteredPrefixes = [this] {
- this->m_face.getIoService().post(bind(&Impl::onEmptyPitOrNoRegisteredPrefixes, this));
+ m_scheduler.scheduleEvent(time::seconds(0), bind(&Impl::onEmptyPitOrNoRegisteredPrefixes, this));
// without this extra "post", transport can get paused (-async_read) and then resumed
// (+async_read) from within onInterest/onData callback. After onInterest/onData
// finishes, there is another +async_read with the same memory block. A few of such
@@ -124,7 +123,7 @@
ensureConnected(bool wantResume)
{
if (!m_face.m_transport->isConnected())
- m_face.m_transport->connect(m_face.m_ioService,
+ m_face.m_transport->connect(m_face.getIoService(),
bind(&Face::onReceiveElement, &m_face, _1));
if (wantResume && !m_face.m_transport->isExpectingData())
@@ -320,23 +319,17 @@
{
if (m_pendingInterestTable.empty() && m_registeredPrefixTable.empty()) {
m_face.m_transport->pause();
- if (!m_ioServiceWork) {
- m_processEventsTimeoutEvent.cancel();
- }
}
}
private:
Face& m_face;
util::Scheduler m_scheduler;
- util::scheduler::ScopedEventId m_processEventsTimeoutEvent;
PendingInterestTable m_pendingInterestTable;
InterestFilterTable m_interestFilterTable;
RegisteredPrefixTable m_registeredPrefixTable;
- unique_ptr<boost::asio::io_service::work> m_ioServiceWork; // if thread needs to be preserved
-
friend class Face;
};