aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-10-10 18:01:28 +0200
committerGitHub <noreply@github.com>2022-10-10 18:01:28 +0200
commit26d9e5da4de4425cbb75cd8fff4374053073b19d (patch)
treebab1c9ca156af7d94b3583d6244a1c09c72e2a81 /vespalib/src/vespa/vespalib/util/generation_hold_list.hpp
parent08f7a121fff008dd1307b106bd1b7d7a84433fe6 (diff)
parentab10d27bd029f73d82dabd1f3fdb839edae29e61 (diff)
Merge pull request #24380 from vespa-engine/geirst/generation-holder-new-implv8.66.20
Implement GenerationHolder in terms of the generic generation hold list.
Diffstat (limited to 'vespalib/src/vespa/vespalib/util/generation_hold_list.hpp')
-rw-r--r--vespalib/src/vespa/vespalib/util/generation_hold_list.hpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp b/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp
index e7eee2b0aef..ed4a99c4753 100644
--- a/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp
+++ b/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp
@@ -1,12 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
#include "generation_hold_list.h"
+#include <cassert>
namespace vespalib {
-template <typename T, bool track_bytes_held>
+template <typename T, bool track_bytes_held, bool use_deque>
void
-GenerationHoldList<T, track_bytes_held>::assign_generation_internal(generation_t current_gen)
+GenerationHoldList<T, track_bytes_held, use_deque>::assign_generation_internal(generation_t current_gen)
{
for (auto& elem : _phase_1_list) {
_phase_2_list.push_back(ElemWithGen(std::move(elem), current_gen));
@@ -14,9 +17,9 @@ GenerationHoldList<T, track_bytes_held>::assign_generation_internal(generation_t
_phase_1_list.clear();
}
-template <typename T, bool track_bytes_held>
+template <typename T, bool track_bytes_held, bool use_deque>
void
-GenerationHoldList<T, track_bytes_held>::reclaim_internal(generation_t oldest_used_gen)
+GenerationHoldList<T, track_bytes_held, use_deque>::reclaim_internal(generation_t oldest_used_gen)
{
auto itr = _phase_2_list.begin();
auto ite = _phase_2_list.end();
@@ -33,17 +36,25 @@ GenerationHoldList<T, track_bytes_held>::reclaim_internal(generation_t oldest_us
}
}
-template <typename T, bool track_bytes_held>
-GenerationHoldList<T, track_bytes_held>::GenerationHoldList()
+template <typename T, bool track_bytes_held, bool use_deque>
+GenerationHoldList<T, track_bytes_held, use_deque>::GenerationHoldList()
: _phase_1_list(),
_phase_2_list(),
_held_bytes()
{
}
-template <typename T, bool track_bytes_held>
+template <typename T, bool track_bytes_held, bool use_deque>
+GenerationHoldList<T, track_bytes_held, use_deque>::~GenerationHoldList()
+{
+ assert(_phase_1_list.empty());
+ assert(_phase_2_list.empty());
+ assert(get_held_bytes() == 0);
+}
+
+template <typename T, bool track_bytes_held, bool use_deque>
void
-GenerationHoldList<T, track_bytes_held>::insert(T data)
+GenerationHoldList<T, track_bytes_held, use_deque>::insert(T data)
{
_phase_1_list.push_back(std::move(data));
if (track_bytes_held) {
@@ -51,9 +62,9 @@ GenerationHoldList<T, track_bytes_held>::insert(T data)
}
}
-template <typename T, bool track_bytes_held>
+template <typename T, bool track_bytes_held, bool use_deque>
void
-GenerationHoldList<T, track_bytes_held>::reclaim_all()
+GenerationHoldList<T, track_bytes_held, use_deque>::reclaim_all()
{
_phase_1_list.clear();
_phase_2_list.clear();