22 #ifndef NDN_DETAIL_PENDING_INTEREST_HPP 23 #define NDN_DETAIL_PENDING_INTEREST_HPP 25 #include "../common.hpp" 26 #include "../interest.hpp" 27 #include "../data.hpp" 28 #include "../util/time.hpp" 29 #include "../util/scheduler.hpp" 30 #include "../util/scheduler-scoped-event-id.hpp" 37 typedef function<void(const Interest&, Data&)>
OnData;
52 const OnTimeout& onTimeout, Scheduler& scheduler)
53 : m_interest(interest)
55 , m_onTimeout(onTimeout)
56 , m_timeoutEvent(scheduler)
59 scheduler.scheduleEvent(m_interest->getInterestLifetime() > time::milliseconds::zero() ?
60 m_interest->getInterestLifetime() :
62 bind(&PendingInterest::invokeTimeoutCallback,
this));
81 m_onData(*m_interest, const_cast<Data&>(data));
99 invokeTimeoutCallback()
102 m_onTimeout(*m_interest);
105 BOOST_ASSERT(m_deleter);
110 shared_ptr<const Interest> m_interest;
111 const OnData m_onData;
112 const OnTimeout m_onTimeout;
114 std::function<void()> m_deleter;
118 class PendingInterestId;
128 : m_id(pendingInterestId)
133 operator()(
const shared_ptr<const PendingInterest>& pendingInterest)
const 135 return (reinterpret_cast<const PendingInterestId*>(
136 &pendingInterest->getInterest()) == m_id);
139 const PendingInterestId* m_id;
145 #endif // NDN_DETAIL_PENDING_INTEREST_HPP Copyright (c) 2011-2015 Regents of the University of California.
void setDeleter(const std::function< void()> &deleter)
Set cleanup function to be called after interest times out.
represents an Interest packet
Functor to match pending interests against PendingInterestId.
function< void(const Interest &)> OnTimeout
PendingInterest(shared_ptr< const Interest > interest, const OnData &onData, const OnTimeout &onTimeout, Scheduler &scheduler)
Create a new PitEntry and set the timeout based on the current time and the interest lifetime...
MatchPendingInterestId(const PendingInterestId *pendingInterestId)
Event that is automatically cancelled upon destruction.
bool operator()(const shared_ptr< const PendingInterest > &pendingInterest) const
function< void(const Interest &, Data &)> OnData
const time::milliseconds DEFAULT_INTEREST_LIFETIME
default value for InterestLifetime
const Interest & getInterest() const
void invokeDataCallback(const Data &data)
invokes the DataCallback