summaryrefslogtreecommitdiff
path: root/src/other_tools/ops_maps
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-06-25 16:14:51 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-06-27 11:24:20 +0200
commit4625d391cad4d04f9adca4484da687b2adb1fed6 (patch)
tree4f4a3e19e78324e6abe3a6ac1209cad3d8a50cb0 /src/other_tools/ops_maps
parent70a854c2ce90194a943b6e007a1515dfc87314eb (diff)
downloadjustbuild-4625d391cad4d04f9adca4484da687b2adb1fed6.tar.gz
Use a raw pointer for passing optional IExecutionApi
...instead of std::optional<gsl::not_null<IExecutionApi const*>>
Diffstat (limited to 'src/other_tools/ops_maps')
-rw-r--r--src/other_tools/ops_maps/archive_fetch_map.cpp8
-rw-r--r--src/other_tools/ops_maps/archive_fetch_map.hpp2
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp10
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp2
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp21
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.hpp2
6 files changed, 23 insertions, 22 deletions
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<IExecutionApi const*> 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<ContentCASMap*> const& content_cas_map,
std::filesystem::path const& fetch_dir,
gsl::not_null<IExecutionApi const*> 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<ArchiveContent, bool>;
gsl::not_null<ContentCASMap*> const& content_cas_map,
std::filesystem::path const& fetch_dir, // should exist!
gsl::not_null<IExecutionApi const*> 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<CriticalGitOpMap*> const& critical_git_op_map,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> 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<ArchiveContent, std::nullptr_t>;
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> 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<IExecutionApi const*> 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<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool backup_to_remote,
gsl::not_null<TaskSystem*> 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<std::string> const& launcher,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> 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<GitTreeInfo, bool>;
std::vector<std::string> const& launcher,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool backup_to_remote,
std::size_t jobs) -> GitTreeFetchMap;