aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-12-15 11:03:11 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-12-15 11:03:11 +0000
commit1e1ebc215480ab75e09f3cd7a016bbdf0831c423 (patch)
tree4781852ea529d7019c41c3c8bcc15f58ad38e6e9 /vespalib
parent684abb75b1967c2fa019d3454627ff95c3435aa8 (diff)
- Add a doom that will not expire until it does not matter anymore.
- Doom can never be null. - Wire doom into fillBitVector. Using it will be a separate PR.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/doom.cpp7
-rw-r--r--vespalib/src/vespa/vespalib/util/doom.h1
-rw-r--r--vespalib/src/vespa/vespalib/util/fake_doom.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/util/fake_doom.h4
4 files changed, 11 insertions, 3 deletions
diff --git a/vespalib/src/vespa/vespalib/util/doom.cpp b/vespalib/src/vespa/vespalib/util/doom.cpp
index 227d43ee4c4..fa036c0c9c7 100644
--- a/vespalib/src/vespa/vespalib/util/doom.cpp
+++ b/vespalib/src/vespa/vespalib/util/doom.cpp
@@ -1,9 +1,14 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "doom.h"
+#include "fake_doom.h"
namespace vespalib {
+namespace {
+ vespalib::FakeDoom practicallyNeverExpire(std::chrono::hours(24*365*100)); // doom in 100 years
+}
+
Doom::Doom(const Clock &clock, steady_time softDoom,
steady_time hardDoom, bool explicitSoftDoom) noexcept
: _clock(clock),
@@ -12,4 +17,6 @@ Doom::Doom(const Clock &clock, steady_time softDoom,
_isExplicitSoftDoom(explicitSoftDoom)
{ }
+const Doom & Doom::armageddon() noexcept { return practicallyNeverExpire.get_doom(); }
+
}
diff --git a/vespalib/src/vespa/vespalib/util/doom.h b/vespalib/src/vespa/vespalib/util/doom.h
index a175bbd20df..bf9d9343b8c 100644
--- a/vespalib/src/vespa/vespalib/util/doom.h
+++ b/vespalib/src/vespa/vespalib/util/doom.h
@@ -19,6 +19,7 @@ public:
duration soft_left() const noexcept { return _softDoom - _clock.getTimeNS(); }
duration hard_left() const noexcept { return _hardDoom - _clock.getTimeNS(); }
bool isExplicitSoftDoom() const noexcept { return _isExplicitSoftDoom; }
+ static const Doom & armageddon() noexcept;
private:
const Clock &_clock;
steady_time _softDoom;
diff --git a/vespalib/src/vespa/vespalib/util/fake_doom.cpp b/vespalib/src/vespa/vespalib/util/fake_doom.cpp
index 51318db135c..d9cbce0b152 100644
--- a/vespalib/src/vespa/vespalib/util/fake_doom.cpp
+++ b/vespalib/src/vespa/vespalib/util/fake_doom.cpp
@@ -4,7 +4,7 @@
namespace vespalib {
-FakeDoom::FakeDoom(steady_time::duration time_to_doom)
+FakeDoom::FakeDoom(steady_time::duration time_to_doom) noexcept
: _time(steady_clock::now()),
_clock(_time),
_doom(_clock, _clock.getTimeNS() + time_to_doom)
diff --git a/vespalib/src/vespa/vespalib/util/fake_doom.h b/vespalib/src/vespa/vespalib/util/fake_doom.h
index 78fc9d0f38a..1e6cfcb0c4d 100644
--- a/vespalib/src/vespa/vespalib/util/fake_doom.h
+++ b/vespalib/src/vespa/vespalib/util/fake_doom.h
@@ -15,8 +15,8 @@ class FakeDoom {
Clock _clock;
Doom _doom;
public:
- FakeDoom() : FakeDoom(1s) { }
- FakeDoom(steady_time::duration time_to_doom);
+ FakeDoom() noexcept : FakeDoom(1s) { }
+ FakeDoom(steady_time::duration time_to_doom) noexcept;
~FakeDoom();
const Doom& get_doom() const noexcept { return _doom; }
};