From 57d583d6b5321766ea896d8368357d8f37520ac1 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sun, 22 Dec 2024 10:49:02 -0600 Subject: [PATCH] refactor --- .../librepertory/include/file_manager/direct_open_file.hpp | 1 + repertory/librepertory/include/file_manager/i_open_file.hpp | 2 +- repertory/librepertory/include/file_manager/open_file.hpp | 2 +- .../librepertory/include/file_manager/open_file_base.hpp | 2 +- repertory/librepertory/src/file_manager/open_file_base.cpp | 6 ++++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/repertory/librepertory/include/file_manager/direct_open_file.hpp b/repertory/librepertory/include/file_manager/direct_open_file.hpp index b0649428..fc14134f 100644 --- a/repertory/librepertory/include/file_manager/direct_open_file.hpp +++ b/repertory/librepertory/include/file_manager/direct_open_file.hpp @@ -69,6 +69,7 @@ public: get_read_state(std::size_t /* chunk */) const -> bool override { return false; } + [[nodiscard]] auto get_total_chunks() const -> std::uint64_t { return total_chunks_; } diff --git a/repertory/librepertory/include/file_manager/i_open_file.hpp b/repertory/librepertory/include/file_manager/i_open_file.hpp index 3f179c6c..d9aeed62 100644 --- a/repertory/librepertory/include/file_manager/i_open_file.hpp +++ b/repertory/librepertory/include/file_manager/i_open_file.hpp @@ -95,7 +95,7 @@ public: [[nodiscard]] virtual auto can_close() const -> bool = 0; - virtual void close() = 0; + virtual auto close() -> bool = 0; [[nodiscard]] virtual auto get_handles() const -> std::vector = 0; diff --git a/repertory/librepertory/include/file_manager/open_file.hpp b/repertory/librepertory/include/file_manager/open_file.hpp index a50f44a1..b02de7ad 100644 --- a/repertory/librepertory/include/file_manager/open_file.hpp +++ b/repertory/librepertory/include/file_manager/open_file.hpp @@ -90,7 +90,7 @@ protected: } public: - void close() override; + auto close() -> bool override; [[nodiscard]] auto get_read_state() const -> boost::dynamic_bitset<> override; diff --git a/repertory/librepertory/include/file_manager/open_file_base.hpp b/repertory/librepertory/include/file_manager/open_file_base.hpp index 119585d5..99860e4b 100644 --- a/repertory/librepertory/include/file_manager/open_file_base.hpp +++ b/repertory/librepertory/include/file_manager/open_file_base.hpp @@ -142,7 +142,7 @@ public: [[nodiscard]] auto can_close() const -> bool override; - void close() override; + auto close() -> bool override; [[nodiscard]] auto get_api_error() const -> api_error; diff --git a/repertory/librepertory/src/file_manager/open_file_base.cpp b/repertory/librepertory/src/file_manager/open_file_base.cpp index dcaa9343..a40aca79 100644 --- a/repertory/librepertory/src/file_manager/open_file_base.cpp +++ b/repertory/librepertory/src/file_manager/open_file_base.cpp @@ -297,12 +297,12 @@ void open_file_base::set_api_path(const std::string &api_path) { fsi_.api_parent = utils::path::get_parent_api_path(api_path); } -void open_file_base::close() { +auto open_file_base::close() -> bool { unique_mutex_lock io_lock(io_thread_mtx_); if (io_stop_requested_ || not io_thread_) { io_thread_notify_.notify_all(); io_lock.unlock(); - return; + return false; } io_stop_requested_ = true; @@ -311,5 +311,7 @@ void open_file_base::close() { io_thread_->join(); io_thread_.reset(); + + return true; } } // namespace repertory