diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-05-31 14:22:50 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-05-31 14:22:50 +0200 |
commit | 690891b6b48124fe05bca22872f923a34ecb5591 (patch) | |
tree | 2253717beb44a0cb5b7077cae60f76d9da17410a /vespalib | |
parent | 45881ba514a564da1891f804a88fe066262884b6 (diff) |
Add Doom to hnsw index.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/CMakeLists.txt | 1 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/fake_doom.cpp | 16 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/fake_doom.h | 24 |
3 files changed, 41 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt index 91365d446c1..21642cbd842 100644 --- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -31,6 +31,7 @@ vespa_add_library(vespalib_vespalib_util OBJECT exceptions.cpp execution_profiler.cpp executor_idle_tracking.cpp + fake_doom.cpp featureset.cpp file_area_freelist.cpp foregroundtaskexecutor.cpp diff --git a/vespalib/src/vespa/vespalib/util/fake_doom.cpp b/vespalib/src/vespa/vespalib/util/fake_doom.cpp new file mode 100644 index 00000000000..4ca71afd2c5 --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/fake_doom.cpp @@ -0,0 +1,16 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "fake_doom.h" + +namespace vespalib { + +FakeDoom::FakeDoom(steady_time::duration time_to_doom) + : _time(steady_clock::now()), + _clock(_time), + _doom(_clock, _clock.getTimeNS() + time_to_doom) +{ +} + +FakeDoom::~FakeDoom() = default; + +} diff --git a/vespalib/src/vespa/vespalib/util/fake_doom.h b/vespalib/src/vespa/vespalib/util/fake_doom.h new file mode 100644 index 00000000000..496129d8f0f --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/fake_doom.h @@ -0,0 +1,24 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "doom.h" + +namespace vespalib { + +/* + * Class containing a fake doom controlled by the time_to_doom + * constructor argument. + */ +class FakeDoom { + std::atomic<steady_time> _time; + Clock _clock; + Doom _doom; +public: + FakeDoom() : FakeDoom(1s) { } + FakeDoom(steady_time::duration time_to_doom); + ~FakeDoom(); + const Doom& get_doom() const noexcept { return _doom; } +}; + +} |