From cc806a0daa7501e5394255f8f1b5f8ea0d67e118 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 26 May 2020 08:57:13 +0100 Subject: [PATCH] [space-maps/disk] add implementation for the variant of inc/dec that take a count --- persistent-data/space-maps/disk.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/persistent-data/space-maps/disk.cc b/persistent-data/space-maps/disk.cc index 4b7db49..df3ab5b 100644 --- a/persistent-data/space-maps/disk.cc +++ b/persistent-data/space-maps/disk.cc @@ -383,23 +383,26 @@ namespace { indexes_->commit_ies(); } - static ref_t inc_mutator(ref_t c) { - return c + 1; - } - - static ref_t dec_mutator(ref_t c) { - return c - 1; - } - - void inc(block_address b) { + void inc(block_address b) override { if (b == search_start_) search_start_++; - modify_count(b, inc_mutator); + modify_count(b, [](ref_t c) {return c + 1;}); } - void dec(block_address b) { - modify_count(b, dec_mutator); + void dec(block_address b) override { + modify_count(b, [](ref_t c) {return c - 1;}); + } + + void inc(block_address b, uint32_t count) override { + if (b == search_start_) + search_start_++; + + modify_count(b, [count](ref_t c) {return c + count;}); + } + + void dec(block_address b, uint32_t count) override { + modify_count(b, [count](ref_t c) {return c - count;}); } maybe_block find_free(span_iterator &it) {