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

This commit is contained in:
Scott E. Graves 2025-02-21 19:53:51 -06:00
parent 9cfc9728bc
commit dd719fe134

View File

@ -266,10 +266,14 @@ void ring_buffer_base::reader_thread() {
REPERTORY_USES_FUNCTION_NAME();
unique_mutex_lock chunk_lock(chunk_mtx_);
const auto notify_and_unlock = [this, &chunk_lock]() {
chunk_notify_.notify_all();
chunk_lock.unlock();
};
auto last_pos = ring_pos_;
auto next_chunk = ring_pos_;
chunk_notify_.notify_all();
chunk_lock.unlock();
notify_and_unlock();
while (not get_stop_requested()) {
chunk_lock.lock();
@ -285,10 +289,10 @@ void ring_buffer_base::reader_thread() {
next_chunk = ring_begin_;
}
const auto check_and_wait = [this, &chunk_lock, &last_pos, &next_chunk]() {
const auto check_and_wait = [this, &chunk_lock, &last_pos, &next_chunk,
&notify_and_unlock]() {
if (get_stop_requested()) {
chunk_notify_.notify_all();
chunk_lock.unlock();
notify_and_unlock();
return;
}
@ -298,8 +302,7 @@ void ring_buffer_base::reader_thread() {
next_chunk = ring_pos_;
}
chunk_notify_.notify_all();
chunk_lock.unlock();
notify_and_unlock();
};
if (read_state_[next_chunk % read_state_.size()]) {
@ -307,9 +310,7 @@ void ring_buffer_base::reader_thread() {
continue;
}
chunk_notify_.notify_all();
chunk_lock.unlock();
notify_and_unlock();
download_chunk(next_chunk, true);
}