This commit is contained in:
2025-10-04 14:49:20 -05:00
parent 72a9005aeb
commit 97a74e5233

View File

@@ -44,7 +44,7 @@ auto open_file_base::download::wait() -> api_error {
unique_mutex_lock lock(mtx_);
if (not complete_) {
notify_.wait(lock);
notify_.wait(lock, [this]() { return complete_; });
}
notify_.notify_all();
@@ -64,7 +64,7 @@ auto open_file_base::io_item::get_result() -> api_error {
return result_.value();
}
notify_.wait(lock);
notify_.wait(lock, [this]() { return result_.has_value(); });
return result_.value_or(api_error::error);
}
@@ -179,7 +179,9 @@ void open_file_base::file_io_thread() {
const auto process_queue = [&]() {
io_lock.lock();
if (not io_stop_requested_ && io_thread_queue_.empty()) {
io_thread_notify_.wait(io_lock);
io_thread_notify_.wait(io_lock, [this]() {
return io_stop_requested_ || not io_thread_queue_.empty();
});
}
while (not io_thread_queue_.empty()) {
@@ -407,7 +409,9 @@ void open_file_base::set_api_path(std::string_view api_path) {
void open_file_base::wait_for_io(stop_type_callback stop_requested_cb) {
unique_mutex_lock io_lock(io_thread_mtx_);
if (not stop_requested_cb() && io_thread_queue_.empty()) {
io_thread_notify_.wait(io_lock);
io_thread_notify_.wait(io_lock, [this, &stop_requested_cb]() {
return stop_requested_cb() || not io_thread_queue_.empty();
});
}
io_thread_notify_.notify_all();
io_lock.unlock();