From 4625d391cad4d04f9adca4484da687b2adb1fed6 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 25 Jun 2024 16:14:51 +0200 Subject: Use a raw pointer for passing optional IExecutionApi ...instead of std::optional> --- src/other_tools/ops_maps/archive_fetch_map.cpp | 8 ++++---- src/other_tools/ops_maps/archive_fetch_map.hpp | 2 +- src/other_tools/ops_maps/content_cas_map.cpp | 10 +++++----- src/other_tools/ops_maps/content_cas_map.hpp | 2 +- src/other_tools/ops_maps/git_tree_fetch_map.cpp | 21 +++++++++++---------- src/other_tools/ops_maps/git_tree_fetch_map.hpp | 2 +- 6 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src/other_tools/ops_maps') diff --git a/src/other_tools/ops_maps/archive_fetch_map.cpp b/src/other_tools/ops_maps/archive_fetch_map.cpp index db2fc319..e035b128 100644 --- a/src/other_tools/ops_maps/archive_fetch_map.cpp +++ b/src/other_tools/ops_maps/archive_fetch_map.cpp @@ -29,17 +29,17 @@ namespace { void ProcessContent(std::filesystem::path const& content_path, std::filesystem::path const& target_name, gsl::not_null const& local_api, - IExecutionApi::OptionalPtr const& remote_api, + IExecutionApi const* remote_api, std::string const& content, ArchiveFetchMap::SetterPtr const& setter, ArchiveFetchMap::LoggerPtr const& logger) { // try to back up to remote CAS - if (remote_api) { + if (remote_api != nullptr) { if (not local_api->RetrieveToCas( {Artifact::ObjectInfo{ .digest = ArtifactDigest{content, 0, /*is_tree=*/false}, .type = ObjectType::File}}, - **remote_api)) { + *remote_api)) { // give a warning (*logger)(fmt::format("Failed to back up content {} from local CAS " "to remote", @@ -70,7 +70,7 @@ void ProcessContent(std::filesystem::path const& content_path, auto CreateArchiveFetchMap(gsl::not_null const& content_cas_map, std::filesystem::path const& fetch_dir, gsl::not_null const& local_api, - IExecutionApi::OptionalPtr const& remote_api, + IExecutionApi const* remote_api, std::size_t jobs) -> ArchiveFetchMap { auto fetch_archive = [content_cas_map, fetch_dir, local_api, remote_api]( auto ts, diff --git a/src/other_tools/ops_maps/archive_fetch_map.hpp b/src/other_tools/ops_maps/archive_fetch_map.hpp index 9f0b220d..6ec3e44c 100644 --- a/src/other_tools/ops_maps/archive_fetch_map.hpp +++ b/src/other_tools/ops_maps/archive_fetch_map.hpp @@ -30,7 +30,7 @@ using ArchiveFetchMap = AsyncMapConsumer; gsl::not_null const& content_cas_map, std::filesystem::path const& fetch_dir, // should exist! gsl::not_null const& local_api, - IExecutionApi::OptionalPtr const& remote_api, + IExecutionApi const* remote_api, std::size_t jobs) -> ArchiveFetchMap; #endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_ARCHIVE_FETCH_MAP_HPP diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp index 3cba65ef..4e526bc7 100644 --- a/src/other_tools/ops_maps/content_cas_map.cpp +++ b/src/other_tools/ops_maps/content_cas_map.cpp @@ -110,7 +110,7 @@ auto CreateContentCASMap( gsl::not_null const& critical_git_op_map, std::optional const& serve, gsl::not_null const& local_api, - IExecutionApi::OptionalPtr const& remote_api, + IExecutionApi const* remote_api, std::size_t jobs) -> ContentCASMap { auto ensure_in_cas = [just_mr_paths, additional_mirrors, @@ -215,10 +215,10 @@ auto CreateContentCASMap( return; } // check if content is known to remote serve service - if (serve and remote_api and + if (serve and remote_api != nullptr and serve->ContentInRemoteCAS(key.content)) { // try to get content from remote CAS - if (remote_api.value()->RetrieveToCas( + if (remote_api->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::File}}, *local_api)) { @@ -229,8 +229,8 @@ auto CreateContentCASMap( } } // check remote execution endpoint, if given - if (remote_api and - remote_api.value()->RetrieveToCas( + if (remote_api != nullptr and + remote_api->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::File}}, *local_api)) { diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp index df8b0103..f0d0369b 100644 --- a/src/other_tools/ops_maps/content_cas_map.hpp +++ b/src/other_tools/ops_maps/content_cas_map.hpp @@ -86,7 +86,7 @@ using ContentCASMap = AsyncMapConsumer; gsl::not_null const& critical_git_op_map, std::optional const& serve, gsl::not_null const& local_api, - IExecutionApi::OptionalPtr const& remote_api, + IExecutionApi const* remote_api, std::size_t jobs) -> ContentCASMap; namespace std { diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp index b08da28a..50433b20 100644 --- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp +++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp @@ -35,7 +35,7 @@ namespace { void BackupToRemote(std::string const& tree_id, - gsl::not_null const& remote_api, + IExecutionApi const& remote_api, GitTreeFetchMap::LoggerPtr const& logger) { // try to back up to remote CAS auto repo = RepositoryConfig{}; @@ -45,7 +45,7 @@ void BackupToRemote(std::string const& tree_id, {Artifact::ObjectInfo{ .digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true}, .type = ObjectType::Tree}}, - *remote_api)) { + remote_api)) { // give a warning (*logger)(fmt::format( "Failed to back up tree {} from local CAS to remote", @@ -67,7 +67,7 @@ void MoveCASTreeToGit(std::string const& tree_id, ArtifactDigest const& digest, gsl::not_null const& import_to_git_map, gsl::not_null const& local_api, - IExecutionApi::OptionalPtr const& remote_api, + IExecutionApi const* remote_api, bool backup_to_remote, gsl::not_null const& ts, GitTreeFetchMap::SetterPtr const& setter, @@ -106,7 +106,7 @@ void MoveCASTreeToGit(std::string const& tree_id, return; } // backup to remote if needed and in compatibility mode - if (backup_to_remote and remote_api) { + if (backup_to_remote and remote_api != nullptr) { BackupToRemote(tree_id, *remote_api, logger); } (*setter)(false /*no cache hit*/); @@ -130,7 +130,7 @@ auto CreateGitTreeFetchMap( std::vector const& launcher, std::optional const& serve, gsl::not_null const& local_api, - IExecutionApi::OptionalPtr const& remote_api, + IExecutionApi const* remote_api, bool backup_to_remote, std::size_t jobs) -> GitTreeFetchMap { auto tree_to_cache = [critical_git_op_map, @@ -204,7 +204,7 @@ auto CreateGitTreeFetchMap( } if (*tree_found) { // backup to remote if needed and in native mode - if (backup_to_remote and remote_api) { + if (backup_to_remote and remote_api != nullptr) { BackupToRemote(key.hash, *remote_api, logger); } // success @@ -231,15 +231,15 @@ auto CreateGitTreeFetchMap( JustMRProgress::Instance().TaskTracker().Start(key.origin); // check if tree is known to remote serve service and can be // made available in remote CAS - if (serve and remote_api) { + if (serve and remote_api != nullptr) { // as we anyway interrogate the remote execution endpoint, // we're only interested here in the serve endpoint making // an attempt to upload the tree, if known, to remote CAS std::ignore = serve->TreeInRemoteCAS(key.hash); } // check if tree is in remote CAS, if a remote is given - if (remote_api and - remote_api.value()->RetrieveToCas( + if (remote_api != nullptr and + remote_api->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, *local_api)) { @@ -463,7 +463,8 @@ auto CreateGitTreeFetchMap( JustMRProgress::Instance().TaskTracker().Stop( key.origin); // backup to remote if needed and in native mode - if (backup_to_remote and remote_api) { + if (backup_to_remote and + remote_api != nullptr) { BackupToRemote( key.hash, *remote_api, logger); } diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.hpp b/src/other_tools/ops_maps/git_tree_fetch_map.hpp index be5a4252..342629ab 100644 --- a/src/other_tools/ops_maps/git_tree_fetch_map.hpp +++ b/src/other_tools/ops_maps/git_tree_fetch_map.hpp @@ -62,7 +62,7 @@ using GitTreeFetchMap = AsyncMapConsumer; std::vector const& launcher, std::optional const& serve, gsl::not_null const& local_api, - IExecutionApi::OptionalPtr const& remote_api, + IExecutionApi const* remote_api, bool backup_to_remote, std::size_t jobs) -> GitTreeFetchMap; -- cgit v1.2.3