diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-01-12 14:26:39 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-01-12 14:26:39 +0100 |
commit | ad2d8672ac1757cfda384e7f126402ee958ded94 (patch) | |
tree | e1017fd05bb51f3f60492eca781a1db2a38aa0be /searchcorespi | |
parent | bd8b40d91afed3ed566677385d7c11643825e4b2 (diff) |
Add sanity check against going past 0.
Diffstat (limited to 'searchcorespi')
3 files changed, 20 insertions, 1 deletions
diff --git a/searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt b/searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt index c1e2b2f3dd1..1987304dc7e 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt +++ b/searchcorespi/src/vespa/searchcorespi/index/CMakeLists.txt @@ -8,6 +8,7 @@ vespa_add_library(searchcorespi_index OBJECT fusionrunner.cpp iindexmanager.cpp iindexcollection.cpp + index_disk_dir_active_state.cpp index_manager_explorer.cpp index_manager_stats.cpp indexcollection.cpp diff --git a/searchcorespi/src/vespa/searchcorespi/index/index_disk_dir_active_state.cpp b/searchcorespi/src/vespa/searchcorespi/index/index_disk_dir_active_state.cpp new file mode 100644 index 00000000000..603971c866e --- /dev/null +++ b/searchcorespi/src/vespa/searchcorespi/index/index_disk_dir_active_state.cpp @@ -0,0 +1,15 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "index_disk_dir_active_state.h" +#include <cassert> + +namespace searchcorespi::index { + +void +IndexDiskDirActiveState::deactivate() noexcept +{ + assert(_active_count > 0u); + --_active_count; +} + +} diff --git a/searchcorespi/src/vespa/searchcorespi/index/index_disk_dir_active_state.h b/searchcorespi/src/vespa/searchcorespi/index/index_disk_dir_active_state.h index 94363b0a113..ac84de5adee 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/index_disk_dir_active_state.h +++ b/searchcorespi/src/vespa/searchcorespi/index/index_disk_dir_active_state.h @@ -1,6 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once +#include <cstdint> + namespace searchcorespi::index { /* @@ -15,7 +18,7 @@ public: } void activate() noexcept { ++_active_count; } - void deactivate() noexcept { --_active_count; } + void deactivate() noexcept; bool is_active() const noexcept { return _active_count != 0; } }; |