18 #include <hicn/transport/config.h>
19 #include <hicn/transport/core/asio_wrapper.h>
20 #include <hicn/transport/core/content_object.h>
21 #include <hicn/transport/core/interest.h>
22 #include <hicn/transport/core/name.h>
23 #include <hicn/transport/interfaces/portal.h>
24 #include <hicn/transport/portability/portability.h>
25 #include <utils/deadline_timer.h>
31 class HicnForwarderInterface;
32 class VPPForwarderInterface;
33 class RawSocketInterface;
37 using OnContentObjectCallback = interface::Portal::OnContentObjectCallback;
38 using OnInterestTimeoutCallback = interface::Portal::OnInterestTimeoutCallback;
44 using Ptr = utils::ObjectPool<PendingInterest>::Ptr;
52 std::unique_ptr<asio::steady_timer> &&timer)
53 : interest_(std::move(interest)),
54 timer_(std::move(timer)),
55 on_content_object_callback_(),
56 on_interest_timeout_callback_() {}
59 OnContentObjectCallback &&on_content_object,
60 OnInterestTimeoutCallback &&on_interest_timeout,
61 std::unique_ptr<asio::steady_timer> &&timer)
62 : interest_(std::move(interest)),
63 timer_(std::move(timer)),
64 on_content_object_callback_(std::move(on_content_object)),
65 on_interest_timeout_callback_(std::move(on_interest_timeout)) {}
69 template <
typename Handler>
70 TRANSPORT_ALWAYS_INLINE
void startCountdown(Handler &&cb) {
71 timer_->expires_from_now(
72 std::chrono::milliseconds(interest_->getLifetime()));
73 timer_->async_wait(std::forward<Handler &&>(cb));
76 TRANSPORT_ALWAYS_INLINE
void cancelTimer() { timer_->cancel(); }
78 TRANSPORT_ALWAYS_INLINE Interest::Ptr &&getInterest() {
79 return std::move(interest_);
82 TRANSPORT_ALWAYS_INLINE
void setInterest(Interest::Ptr &interest) {
86 TRANSPORT_ALWAYS_INLINE
const OnContentObjectCallback &getOnDataCallback()
88 return on_content_object_callback_;
91 TRANSPORT_ALWAYS_INLINE
void setOnContentObjectCallback(
92 OnContentObjectCallback &&on_content_object) {
93 PendingInterest::on_content_object_callback_ = on_content_object;
96 TRANSPORT_ALWAYS_INLINE
const OnInterestTimeoutCallback &
97 getOnTimeoutCallback()
const {
98 return on_interest_timeout_callback_;
101 TRANSPORT_ALWAYS_INLINE
void setOnTimeoutCallback(
102 OnInterestTimeoutCallback &&on_interest_timeout) {
103 PendingInterest::on_interest_timeout_callback_ = on_interest_timeout;
107 Interest::Ptr interest_;
108 std::unique_ptr<asio::steady_timer> timer_;
109 OnContentObjectCallback on_content_object_callback_;
110 OnInterestTimeoutCallback on_interest_timeout_callback_;