refactor: pass perfmon shared_ptr by const reference

This commit is contained in:
Marcus Holland-Moritz 2025-03-16 18:31:35 +01:00
parent ba0bdbdc91
commit fdddf95bfc
8 changed files with 49 additions and 47 deletions

View File

@ -75,16 +75,17 @@ class filesystem_v2 {
filesystem_v2(logger& lgr, os_access const& os, filesystem_v2(logger& lgr, os_access const& os,
std::filesystem::path const& path); std::filesystem::path const& path);
filesystem_v2(logger& lgr, os_access const& os, filesystem_v2(
std::filesystem::path const& path, logger& lgr, os_access const& os, std::filesystem::path const& path,
filesystem_options const& options, filesystem_options const& options,
std::shared_ptr<performance_monitor const> perfmon = nullptr); std::shared_ptr<performance_monitor const> const& perfmon = nullptr);
filesystem_v2(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm); filesystem_v2(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm);
filesystem_v2(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm, filesystem_v2(
filesystem_options const& options, logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
std::shared_ptr<performance_monitor const> perfmon = nullptr); filesystem_options const& options,
std::shared_ptr<performance_monitor const> const& perfmon = nullptr);
static int static int
identify(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm, identify(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,

View File

@ -55,7 +55,7 @@ class block_cache {
public: public:
block_cache(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm, block_cache(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
const block_cache_options& options, const block_cache_options& options,
std::shared_ptr<performance_monitor const> perfmon); std::shared_ptr<performance_monitor const> const& perfmon);
size_t block_count() const { return impl_->block_count(); } size_t block_count() const { return impl_->block_count(); }

View File

@ -54,7 +54,7 @@ class inode_reader_v2 {
inode_reader_v2(logger& lgr, block_cache&& bc, inode_reader_v2(logger& lgr, block_cache&& bc,
inode_reader_options const& opts, inode_reader_options const& opts,
std::shared_ptr<performance_monitor const> perfmon); std::shared_ptr<performance_monitor const> const& perfmon);
inode_reader_v2& operator=(inode_reader_v2&&) = default; inode_reader_v2& operator=(inode_reader_v2&&) = default;

View File

@ -65,10 +65,11 @@ class metadata_v2 {
metadata_v2(metadata_v2&&) = default; metadata_v2(metadata_v2&&) = default;
metadata_v2& operator=(metadata_v2&&) = default; metadata_v2& operator=(metadata_v2&&) = default;
metadata_v2(logger& lgr, std::span<uint8_t const> schema, metadata_v2(
std::span<uint8_t const> data, metadata_options const& options, logger& lgr, std::span<uint8_t const> schema,
int inode_offset = 0, bool force_consistency_check = false, std::span<uint8_t const> data, metadata_options const& options,
std::shared_ptr<performance_monitor const> perfmon = nullptr); int inode_offset = 0, bool force_consistency_check = false,
std::shared_ptr<performance_monitor const> const& perfmon = nullptr);
void check_consistency() const { impl_->check_consistency(); } void check_consistency() const { impl_->check_consistency(); }

View File

@ -153,11 +153,10 @@ metadata_v2
make_metadata(logger& lgr, std::shared_ptr<mmif> mm, make_metadata(logger& lgr, std::shared_ptr<mmif> mm,
section_map const& sections, std::vector<uint8_t>& schema_buffer, section_map const& sections, std::vector<uint8_t>& schema_buffer,
std::vector<uint8_t>& meta_buffer, std::vector<uint8_t>& meta_buffer,
const metadata_options& options, int inode_offset = 0, const metadata_options& options, int inode_offset,
bool force_buffers = false, bool force_buffers, mlock_mode lock_mode,
mlock_mode lock_mode = mlock_mode::NONE, bool force_consistency_check,
bool force_consistency_check = false, std::shared_ptr<performance_monitor const> const& perfmon) {
std::shared_ptr<performance_monitor const> perfmon = nullptr) {
LOG_PROXY(debug_logger_policy, lgr); LOG_PROXY(debug_logger_policy, lgr);
auto schema_it = sections.find(section_type::METADATA_V2_SCHEMA); auto schema_it = sections.find(section_type::METADATA_V2_SCHEMA);
auto meta_it = sections.find(section_type::METADATA_V2); auto meta_it = sections.find(section_type::METADATA_V2);
@ -217,7 +216,7 @@ class filesystem_ final : public filesystem_v2::impl {
public: public:
filesystem_(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm, filesystem_(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
const filesystem_options& options, const filesystem_options& options,
std::shared_ptr<performance_monitor const> perfmon); std::shared_ptr<performance_monitor const> const& perfmon);
int check(filesystem_check_level level, size_t num_threads) const override; int check(filesystem_check_level level, size_t num_threads) const override;
void dump(std::ostream& os, fsinfo_options const& opts) const override; void dump(std::ostream& os, fsinfo_options const& opts) const override;
@ -438,7 +437,7 @@ template <typename LoggerPolicy>
filesystem_<LoggerPolicy>::filesystem_( filesystem_<LoggerPolicy>::filesystem_(
logger& lgr, os_access const& os, std::shared_ptr<mmif> mm, logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
filesystem_options const& options, filesystem_options const& options,
std::shared_ptr<performance_monitor const> perfmon) std::shared_ptr<performance_monitor const> const& perfmon)
: LOG_PROXY_INIT(lgr) : LOG_PROXY_INIT(lgr)
, os_{os} , os_{os}
, mm_{std::move(mm)} , mm_{std::move(mm)}
@ -1106,24 +1105,24 @@ filesystem_v2::filesystem_v2(logger& lgr, os_access const& os,
std::filesystem::path const& path) std::filesystem::path const& path)
: filesystem_v2(lgr, os, os.map_file(os.canonical(path))) {} : filesystem_v2(lgr, os, os.map_file(os.canonical(path))) {}
filesystem_v2::filesystem_v2(logger& lgr, os_access const& os, filesystem_v2::filesystem_v2(
std::filesystem::path const& path, logger& lgr, os_access const& os, std::filesystem::path const& path,
filesystem_options const& options, filesystem_options const& options,
std::shared_ptr<performance_monitor const> perfmon) std::shared_ptr<performance_monitor const> const& perfmon)
: filesystem_v2(lgr, os, os.map_file(os.canonical(path)), options, : filesystem_v2(lgr, os, os.map_file(os.canonical(path)), options,
std::move(perfmon)) {} perfmon) {}
filesystem_v2::filesystem_v2(logger& lgr, os_access const& os, filesystem_v2::filesystem_v2(logger& lgr, os_access const& os,
std::shared_ptr<mmif> mm) std::shared_ptr<mmif> mm)
: filesystem_v2(lgr, os, std::move(mm), filesystem_options()) {} : filesystem_v2(lgr, os, std::move(mm), filesystem_options()) {}
filesystem_v2::filesystem_v2(logger& lgr, os_access const& os, filesystem_v2::filesystem_v2(
std::shared_ptr<mmif> mm, logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
const filesystem_options& options, const filesystem_options& options,
std::shared_ptr<performance_monitor const> perfmon) std::shared_ptr<performance_monitor const> const& perfmon)
: impl_(make_unique_logging_object<filesystem_v2::impl, : impl_(make_unique_logging_object<filesystem_v2::impl,
internal::filesystem_, logger_policies>( internal::filesystem_, logger_policies>(
lgr, os, std::move(mm), options, std::move(perfmon))) {} lgr, os, std::move(mm), options, perfmon)) {}
int filesystem_v2::identify(logger& lgr, os_access const& os, int filesystem_v2::identify(logger& lgr, os_access const& os,
std::shared_ptr<mmif> mm, std::ostream& output, std::shared_ptr<mmif> mm, std::ostream& output,

View File

@ -219,7 +219,7 @@ class block_cache_ final : public block_cache::impl {
public: public:
block_cache_(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm, block_cache_(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
block_cache_options const& options, block_cache_options const& options,
std::shared_ptr<performance_monitor const> perfmon std::shared_ptr<performance_monitor const> const& perfmon
[[maybe_unused]]) [[maybe_unused]])
: cache_(0) : cache_(0)
, mm_(std::move(mm)) , mm_(std::move(mm))
@ -802,11 +802,11 @@ class block_cache_ final : public block_cache::impl {
} // namespace } // namespace
block_cache::block_cache(logger& lgr, os_access const& os, block_cache::block_cache(
std::shared_ptr<mmif> mm, logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
const block_cache_options& options, const block_cache_options& options,
std::shared_ptr<performance_monitor const> perfmon) std::shared_ptr<performance_monitor const> const& perfmon)
: impl_(make_unique_logging_object<impl, block_cache_, logger_policies>( : impl_(make_unique_logging_object<impl, block_cache_, logger_policies>(
lgr, os, std::move(mm), options, std::move(perfmon))) {} lgr, os, std::move(mm), options, perfmon)) {}
} // namespace dwarfs::reader::internal } // namespace dwarfs::reader::internal

View File

@ -99,7 +99,7 @@ template <typename LoggerPolicy>
class inode_reader_ final : public inode_reader_v2::impl { class inode_reader_ final : public inode_reader_v2::impl {
public: public:
inode_reader_(logger& lgr, block_cache&& bc, inode_reader_options const& opts, inode_reader_(logger& lgr, block_cache&& bc, inode_reader_options const& opts,
std::shared_ptr<performance_monitor const> perfmon std::shared_ptr<performance_monitor const> const& perfmon
[[maybe_unused]]) [[maybe_unused]])
: cache_(std::move(bc)) : cache_(std::move(bc))
, opts_{opts} , opts_{opts}
@ -457,9 +457,9 @@ size_t inode_reader_<LoggerPolicy>::readv(iovec_read_buf& buf, uint32_t inode,
inode_reader_v2::inode_reader_v2( inode_reader_v2::inode_reader_v2(
logger& lgr, block_cache&& bc, inode_reader_options const& opts, logger& lgr, block_cache&& bc, inode_reader_options const& opts,
std::shared_ptr<performance_monitor const> perfmon) std::shared_ptr<performance_monitor const> const& perfmon)
: impl_(make_unique_logging_object<inode_reader_v2::impl, inode_reader_, : impl_(make_unique_logging_object<inode_reader_v2::impl, inode_reader_,
logger_policies>( logger_policies>(lgr, std::move(bc),
lgr, std::move(bc), opts, std::move(perfmon))) {} opts, perfmon)) {}
} // namespace dwarfs::reader::internal } // namespace dwarfs::reader::internal

View File

@ -397,7 +397,8 @@ class metadata_ final : public metadata_v2::impl {
metadata_(logger& lgr, std::span<uint8_t const> schema, metadata_(logger& lgr, std::span<uint8_t const> schema,
std::span<uint8_t const> data, metadata_options const& options, std::span<uint8_t const> data, metadata_options const& options,
int inode_offset, bool force_consistency_check, int inode_offset, bool force_consistency_check,
std::shared_ptr<performance_monitor const> perfmon [[maybe_unused]]) std::shared_ptr<performance_monitor const> const& perfmon
[[maybe_unused]])
: data_(data) : data_(data)
, meta_( , meta_(
check_frozen(map_frozen<thrift::metadata::metadata>(schema, data_))) check_frozen(map_frozen<thrift::metadata::metadata>(schema, data_)))
@ -2193,14 +2194,14 @@ std::vector<file_stat::gid_type> metadata_<LoggerPolicy>::get_all_gids() const {
return rv; return rv;
} }
metadata_v2::metadata_v2(logger& lgr, std::span<uint8_t const> schema, metadata_v2::metadata_v2(
std::span<uint8_t const> data, logger& lgr, std::span<uint8_t const> schema, std::span<uint8_t const> data,
metadata_options const& options, int inode_offset, metadata_options const& options, int inode_offset,
bool force_consistency_check, bool force_consistency_check,
std::shared_ptr<performance_monitor const> perfmon) std::shared_ptr<performance_monitor const> const& perfmon)
: impl_(make_unique_logging_object<metadata_v2::impl, metadata_, : impl_(make_unique_logging_object<metadata_v2::impl, metadata_,
logger_policies>( logger_policies>(
lgr, schema, data, options, inode_offset, force_consistency_check, lgr, schema, data, options, inode_offset, force_consistency_check,
std::move(perfmon))) {} perfmon)) {}
} // namespace dwarfs::reader::internal } // namespace dwarfs::reader::internal