diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-01-29 15:49:15 +0100 |
---|---|---|
committer | Michele Papalini <micpapal@cisco.com> | 2019-01-29 17:30:27 +0000 |
commit | 51ff9b669dff18c9300b9fe5bdef91e7040edac0 (patch) | |
tree | 286625282289580594c0ecf7dcf3df47a7ed8a18 /libtransport/src/hicn/transport/core/portal.h | |
parent | a2e898eae8086cded2acfa96347184b3aa88d316 (diff) |
[HICN-17] Add possibility to destroy connection directly from stopEventsLoop with an additional parameter.
Change-Id: I869a079a7b2f436768a62de66fd9281a7d1243cd
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/core/portal.h')
-rw-r--r-- | libtransport/src/hicn/transport/core/portal.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/libtransport/src/hicn/transport/core/portal.h b/libtransport/src/hicn/transport/core/portal.h index 52a721a35..58406bbde 100644 --- a/libtransport/src/hicn/transport/core/portal.h +++ b/libtransport/src/hicn/transport/core/portal.h @@ -97,9 +97,7 @@ class Portal { virtual void onInterest(Interest::Ptr &&i) = 0; }; - Portal() : Portal(internal_io_service_) { - internal_work_ = std::make_unique<asio::io_service::work>(io_service_); - } + Portal() : Portal(internal_io_service_) {} Portal(asio::io_service &io_service) : io_service_(io_service), @@ -130,8 +128,7 @@ class Portal { } ~Portal() { - connector_.close(); - stopEventsLoop(); + stopEventsLoop(true); } TRANSPORT_ALWAYS_INLINE bool interestIsPending(const Name &name) { @@ -227,15 +224,17 @@ class Portal { forwarder_interface_.send(content_object); } - TRANSPORT_ALWAYS_INLINE void stopEventsLoop() { - internal_work_.reset(); - + TRANSPORT_ALWAYS_INLINE void stopEventsLoop(bool kill_connection = false) { for (auto &pend_interest : pending_interest_hash_table_) { pend_interest.second->cancelTimer(); } clear(); + if(kill_connection) { + connector_.close(); + } + io_service_.post([this]() { io_service_.stop(); }); } @@ -340,7 +339,6 @@ class Portal { private: asio::io_service &io_service_; asio::io_service internal_io_service_; - std::unique_ptr<asio::io_service::work> internal_work_; std::string app_name_; |