diff --git a/repertory/librepertory/src/file_manager/open_file_base.cpp b/repertory/librepertory/src/file_manager/open_file_base.cpp index d24e655a..822641cf 100644 --- a/repertory/librepertory/src/file_manager/open_file_base.cpp +++ b/repertory/librepertory/src/file_manager/open_file_base.cpp @@ -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();