aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/utils/suffix_strategy.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/utils/suffix_strategy.h')
-rw-r--r--libtransport/src/utils/suffix_strategy.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/libtransport/src/utils/suffix_strategy.h b/libtransport/src/utils/suffix_strategy.h
index 6c4dd2785..ee016308e 100644
--- a/libtransport/src/utils/suffix_strategy.h
+++ b/libtransport/src/utils/suffix_strategy.h
@@ -33,6 +33,8 @@ class SuffixStrategy {
virtual ~SuffixStrategy() = default;
+ virtual uint32_t checkNextSuffix() = 0;
+
virtual uint32_t getNextSuffix() = 0;
virtual uint32_t getFinalSuffix() { return final_suffix_; }
@@ -43,8 +45,12 @@ class SuffixStrategy {
}
}
+ virtual uint32_t checkNextManifestSuffix() = 0;
+
virtual uint32_t getNextManifestSuffix() = 0;
+ virtual uint32_t checkNextContentSuffix() = 0;
+
virtual uint32_t getNextContentSuffix() = 0;
virtual void reset(uint32_t offset = 0) = 0;
@@ -74,15 +80,27 @@ class IncrementalSuffixStrategy : public SuffixStrategy {
: SuffixStrategy(NextSegmentCalculationStrategy::INCREMENTAL),
next_suffix_(start_offset) {}
+ TRANSPORT_ALWAYS_INLINE std::uint32_t checkNextSuffix() override {
+ return next_suffix_;
+ }
+
TRANSPORT_ALWAYS_INLINE std::uint32_t getNextSuffix() override {
incrementTotalCount();
return next_suffix_++;
}
+ TRANSPORT_ALWAYS_INLINE std::uint32_t checkNextContentSuffix() override {
+ return checkNextSuffix();
+ }
+
TRANSPORT_ALWAYS_INLINE std::uint32_t getNextContentSuffix() override {
return getNextSuffix();
}
+ TRANSPORT_ALWAYS_INLINE std::uint32_t checkNextManifestSuffix() override {
+ return checkNextSuffix();
+ }
+
TRANSPORT_ALWAYS_INLINE std::uint32_t getNextManifestSuffix() override {
return getNextSuffix();
}
@@ -112,17 +130,30 @@ class CapacityBasedSuffixStrategy : public SuffixStrategy {
segments_in_manifest_(manifest_capacity),
current_manifest_iteration_(0) {}
+ TRANSPORT_ALWAYS_INLINE std::uint32_t checkNextSuffix() override {
+ return next_suffix_;
+ }
+
TRANSPORT_ALWAYS_INLINE std::uint32_t getNextSuffix() override {
incrementTotalCount();
return next_suffix_++;
}
+ TRANSPORT_ALWAYS_INLINE std::uint32_t checkNextContentSuffix() override {
+ return next_suffix_ % segments_in_manifest_ == 0 ? next_suffix_
+ : (next_suffix_ + 1);
+ }
+
TRANSPORT_ALWAYS_INLINE std::uint32_t getNextContentSuffix() override {
incrementTotalCount();
return next_suffix_ % segments_in_manifest_ == 0 ? next_suffix_++
: ++next_suffix_;
}
+ TRANSPORT_ALWAYS_INLINE std::uint32_t checkNextManifestSuffix() override {
+ return (current_manifest_iteration_ + 1) * (segments_in_manifest_ + 1);
+ }
+
TRANSPORT_ALWAYS_INLINE std::uint32_t getNextManifestSuffix() override {
incrementTotalCount();
return (current_manifest_iteration_++) * (segments_in_manifest_ + 1);