This commit is contained in:
parent
9cfc9728bc
commit
dd719fe134
@ -266,10 +266,14 @@ void ring_buffer_base::reader_thread() {
|
|||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
unique_mutex_lock chunk_lock(chunk_mtx_);
|
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 last_pos = ring_pos_;
|
||||||
auto next_chunk = ring_pos_;
|
auto next_chunk = ring_pos_;
|
||||||
chunk_notify_.notify_all();
|
notify_and_unlock();
|
||||||
chunk_lock.unlock();
|
|
||||||
|
|
||||||
while (not get_stop_requested()) {
|
while (not get_stop_requested()) {
|
||||||
chunk_lock.lock();
|
chunk_lock.lock();
|
||||||
@ -285,10 +289,10 @@ void ring_buffer_base::reader_thread() {
|
|||||||
next_chunk = ring_begin_;
|
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()) {
|
if (get_stop_requested()) {
|
||||||
chunk_notify_.notify_all();
|
notify_and_unlock();
|
||||||
chunk_lock.unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,8 +302,7 @@ void ring_buffer_base::reader_thread() {
|
|||||||
next_chunk = ring_pos_;
|
next_chunk = ring_pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_notify_.notify_all();
|
notify_and_unlock();
|
||||||
chunk_lock.unlock();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (read_state_[next_chunk % read_state_.size()]) {
|
if (read_state_[next_chunk % read_state_.size()]) {
|
||||||
@ -307,9 +310,7 @@ void ring_buffer_base::reader_thread() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_notify_.notify_all();
|
notify_and_unlock();
|
||||||
chunk_lock.unlock();
|
|
||||||
|
|
||||||
download_chunk(next_chunk, true);
|
download_chunk(next_chunk, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user