From f2b7325ae6114b6b5b9e4d32c0a7cdc07576f224 Mon Sep 17 00:00:00 2001 From: Olivier Roques Date: Thu, 7 Nov 2019 10:05:52 +0000 Subject: [HICN-392] Assign independent suffixes for manifests/contents This patch introduces a new class, SuffixStrategy and two sub-classes, SuffixContent and SuffixManifest which allow to independently assign suffixes to contents and manifests respectively. The produce() function in socket_producer.cc has also been changed to use them. Given a strategy and an offset (and optionally the capacity of a manifest), these classes automatically compute the correct next suffixes for both type of data (manifest or content). This removes the burden of having to manage suffixes for instance when producing or when retrieving content, and could be expanded to add more strategy in the future. Currently the only existing strategy is "INCREMENTAL": manifests with capacity N have a suffix multiple of N+1: 0, N+1, 2(N+1) etc. Contents have a suffix incremented by 1 except when it conflicts with a manifest: 1, 2, ..., N, N+2, N+3, ..., 2N+1, 2N+3... Signed-off-by: Olivier Roques Change-Id: Ia7692d7325240de7bea6e38b668077042e5f8758 Signed-off-by: Alberto Compagno --- libtransport/src/hicn/transport/interfaces/socket_producer.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libtransport/src/hicn/transport/interfaces/socket_producer.h') diff --git a/libtransport/src/hicn/transport/interfaces/socket_producer.h b/libtransport/src/hicn/transport/interfaces/socket_producer.h index 709a2582b..952587b70 100644 --- a/libtransport/src/hicn/transport/interfaces/socket_producer.h +++ b/libtransport/src/hicn/transport/interfaces/socket_producer.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -190,6 +191,8 @@ class ProducerSocket : public Socket, std::atomic crypto_suite_; utils::SpinLock identity_lock_; std::shared_ptr identity_; + utils::SuffixManifest suffix_manifest_; + utils::SuffixContent suffix_content_; // callbacks ProducerInterestCallback on_interest_input_; @@ -220,8 +223,8 @@ class ProducerSocket : public Socket, /* Condition variable for the wait */ std::condition_variable cv; bool done = false; - io_service_.dispatch([&socket_option_key, &socket_option_value, - &mtx, &cv, &result, &done, &func]() { + io_service_.dispatch([&socket_option_key, &socket_option_value, &mtx, &cv, + &result, &done, &func]() { std::unique_lock lck(mtx); done = true; result = func(socket_option_key, socket_option_value); @@ -247,4 +250,4 @@ class ProducerSocket : public Socket, } // namespace interface -} // namespace transport \ No newline at end of file +} // namespace transport -- cgit 1.2.3-korg