Skip to content

Commit

Permalink
add helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Forairaaaaa committed Jan 27, 2024
1 parent 886951b commit 74c30bb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/utils/ring_buffer/ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace SmoothUIToolKit
return true;
}

bool peekAll(std::function<void(T)> valueCallback)
bool peekAll(std::function<void(const T&)> valueCallback)
{
if (isEmpty())
return false;
Expand Down Expand Up @@ -140,5 +140,13 @@ namespace SmoothUIToolKit
const size_t& readIndex() { return _data.r_index; }

const size_t& writeIndex() { return _data.w_index; }

const T& lastValue()
{
if (_data.w_index == 0)
return _data.buffer[_data.capacity - 1];
else
return _data.buffer[_data.w_index - 1];
}
};
} // namespace SmoothUIToolKit

0 comments on commit 74c30bb

Please sign in to comment.