refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2024-12-22 19:00:22 -06:00
parent 73a8b2c9fc
commit 13f6c10e6e

View File

@ -172,18 +172,16 @@ void ring_buffer_open_file::forward(std::size_t count) {
ring_state_.set(0U, ring_state_.size(), true); ring_state_.set(0U, ring_state_.size(), true);
ring_pos_ += count; ring_pos_ += count;
ring_begin_ += added; ring_begin_ += added;
ring_end_ =
std::min(total_chunks_ - 1U, ring_begin_ + ring_state_.size() - 1U);
} else { } else {
for (std::size_t idx = 0U; idx < added; ++idx) { for (std::size_t idx = 0U; idx < added; ++idx) {
ring_state_[(ring_begin_ + idx) % ring_state_.size()] = true; ring_state_[(ring_begin_ + idx) % ring_state_.size()] = true;
} }
ring_begin_ += added; ring_begin_ += added;
ring_pos_ += count; ring_pos_ += count;
}
ring_end_ = ring_end_ =
std::min(total_chunks_ - 1U, ring_begin_ + ring_state_.size() - 1U); std::min(total_chunks_ - 1U, ring_begin_ + ring_state_.size() - 1U);
} }
}
chunk_notify_.notify_all(); chunk_notify_.notify_all();
} }
@ -218,18 +216,17 @@ void ring_buffer_open_file::reverse(std::size_t count) {
ring_state_.set(0U, ring_state_.size(), true); ring_state_.set(0U, ring_state_.size(), true);
ring_pos_ -= count; ring_pos_ -= count;
ring_begin_ = ring_pos_; ring_begin_ = ring_pos_;
ring_end_ =
std::min(total_chunks_ - 1U, ring_begin_ + ring_state_.size() - 1U);
} else { } else {
for (std::size_t idx = 0U; idx < removed; ++idx) { for (std::size_t idx = 0U; idx < removed; ++idx) {
ring_state_[(ring_end_ - idx) % ring_state_.size()] = true; ring_state_[(ring_end_ - idx) % ring_state_.size()] = true;
} }
ring_begin_ -= removed; ring_begin_ -= removed;
ring_pos_ -= count; ring_pos_ -= count;
}
ring_end_ = ring_end_ =
std::min(total_chunks_ - 1U, ring_begin_ + ring_state_.size() - 1U); std::min(total_chunks_ - 1U, ring_begin_ + ring_state_.size() - 1U);
} }
}
chunk_notify_.notify_all(); chunk_notify_.notify_all();
} }