Skip to content

refactor(buffer): consolidate load_average_history with time_series_buffer#315

Merged
kcenon merged 2 commits into
mainfrom
refactor/consolidate-load-average-history-311
Jan 3, 2026
Merged

refactor(buffer): consolidate load_average_history with time_series_buffer#315
kcenon merged 2 commits into
mainfrom
refactor/consolidate-load-average-history-311

Conversation

@kcenon

@kcenon kcenon commented Jan 3, 2026

Copy link
Copy Markdown
Owner

Summary

Extract common ring buffer logic into detail::time_series_ring_buffer<Sample> template class to eliminate ~90% code duplication between time_series_buffer<T> and load_average_history.

Changes

  • Add time_series_ring_buffer<Sample> as internal base implementation in detail namespace
  • Refactor time_series_buffer<T> to use the new base class
  • Refactor load_average_history to use the new base class
  • Add missing <stdexcept> header include

Benefits

  • No Duplication: Single ring buffer implementation for time-series data
  • Maintainability: Bug fixes only need to be applied once
  • No Breaking Changes: Public API remains unchanged

Test Plan

  • All 26 TimeSeriesBuffer and LoadAverageHistory tests pass
  • Thread safety tests pass
  • Statistics calculation tests pass
  • Full test suite passes (462/464, 2 pre-existing hardware-related failures)

Closes #311

kcenon added 2 commits January 3, 2026 17:18
…uffer

Extract common ring buffer logic into detail::time_series_ring_buffer<Sample>
template class to eliminate code duplication between time_series_buffer<T>
and load_average_history.

Changes:
- Add time_series_ring_buffer<Sample> as internal base implementation
- Refactor time_series_buffer<T> to use the new base class
- Refactor load_average_history to use the new base class
- Add missing <stdexcept> header include

This reduces ~90% code duplication while maintaining the same public API.
All existing tests pass.

Closes #311
Use common::Result<T>::err() to propagate errors from the base ring
buffer class instead of attempting to convert error codes.
@kcenon kcenon merged commit fc0f247 into main Jan 3, 2026
21 checks passed
@kcenon kcenon deleted the refactor/consolidate-load-average-history-311 branch January 3, 2026 08:36
kcenon added a commit that referenced this pull request Apr 13, 2026
…uffer (#315)

* refactor(buffer): consolidate load_average_history with time_series_buffer

Extract common ring buffer logic into detail::time_series_ring_buffer<Sample>
template class to eliminate code duplication between time_series_buffer<T>
and load_average_history.

Changes:
- Add time_series_ring_buffer<Sample> as internal base implementation
- Refactor time_series_buffer<T> to use the new base class
- Refactor load_average_history to use the new base class
- Add missing <stdexcept> header include

This reduces ~90% code duplication while maintaining the same public API.
All existing tests pass.

Closes #311

* fix(buffer): correct error propagation in get_latest method

Use common::Result<T>::err() to propagate errors from the base ring
buffer class instead of attempting to convert error codes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] Consolidate load_average_history with time_series_buffer

1 participant