This commit is contained in:
parent
9cfc9728bc
commit
dd719fe134
@ -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,
|
||||
¬ify_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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user