7 #ifndef NDN_DETAIL_PENDING_INTEREST_HPP
8 #define NDN_DETAIL_PENDING_INTEREST_HPP
10 #include "../common.hpp"
11 #include "../interest.hpp"
12 #include "../data.hpp"
13 #include "../util/time.hpp"
20 typedef function<void(const Interest&, Data&)>
OnData;
36 , m_onTimeout(onTimeout)
38 if (interest_->getInterestLifetime() >= time::milliseconds::zero())
39 m_timeout = time::steady_clock::now() + interest_->getInterestLifetime();
44 const shared_ptr<const Interest>&
63 return now >= m_timeout;
73 m_onTimeout(*interest_);
78 shared_ptr<const Interest> interest_;
85 struct PendingInterestId;
93 : m_id(pendingInterestId)
98 operator()(
const shared_ptr<const PendingInterest>& pendingInterest)
const
100 return (reinterpret_cast<const PendingInterestId*>(pendingInterest.get()) == m_id);
103 const PendingInterestId* m_id;
109 #endif // NDN_DETAIL_PENDING_INTEREST_HPP
bool operator()(const shared_ptr< const PendingInterest > &pendingInterest) const
MatchPendingInterestId(const PendingInterestId *pendingInterestId)
const shared_ptr< const Interest > & getInterest()
function< void(const Interest &)> OnTimeout
An OnTimeout function object is used to pass a callback to expressInterest.
function< void(const Interest &)> OnTimeout
bool isTimedOut(const time::steady_clock::TimePoint &now)
Check if this interest is timed out.
const time::seconds DEFAULT_INTEREST_LIFETIME
PendingInterest(const shared_ptr< const Interest > &interest, const OnData &onData, const OnTimeout &onTimeout)
Create a new PitEntry and set the timeout based on the current time and the interest lifetime...
function< void(const Interest &, Data &)> OnData
An OnData function object is used to pass a callback to expressInterest.
Functor to match pending interests against PendingInterestId.
function< void(const Interest &, Data &)> OnData
void callTimeout()
Call m_onTimeout (if defined).
const OnData & getOnData()