summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/execution_service/execution_server.cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-08-07 15:44:23 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-08-07 15:44:23 +0200
commit24ff00ff5049c79fbc79ffded9b8e9da15186d2c (patch)
treeeb07cba226b9f8c9758d1ad366985e77a23ad8d4 /src/buildtool/execution_api/execution_service/execution_server.cpp
parent61242ccdb8dcc0f4541172af903a493c2f3a9568 (diff)
downloadjustbuild-24ff00ff5049c79fbc79ffded9b8e9da15186d2c.tar.gz
Pass a longrunning operation to ExecutionServer::WriteResult by rvalue
Diffstat (limited to 'src/buildtool/execution_api/execution_service/execution_server.cpp')
-rw-r--r--src/buildtool/execution_api/execution_service/execution_server.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp
index 1576c56c..16202975 100644
--- a/src/buildtool/execution_api/execution_service/execution_server.cpp
+++ b/src/buildtool/execution_api/execution_service/execution_server.cpp
@@ -29,7 +29,8 @@
#include "src/utils/cpp/verify_hash.hpp"
namespace {
-void UpdateTimeStamp(::google::longrunning::Operation* op) {
+void UpdateTimeStamp(
+ gsl::not_null<::google::longrunning::Operation*> const& op) {
::google::protobuf::Timestamp t;
t.set_seconds(
std::chrono::duration_cast<std::chrono::seconds>(
@@ -135,15 +136,14 @@ auto ExecutionServiceImpl::ToBazelExecuteResponse(
void ExecutionServiceImpl::WriteResponse(
::bazel_re::ExecuteResponse const& execute_response,
::grpc::ServerWriter<::google::longrunning::Operation>* writer,
- ::google::longrunning::Operation* op) noexcept {
-
+ ::google::longrunning::Operation&& op) noexcept {
// send response to the client
- op->mutable_response()->PackFrom(execute_response);
- op->set_done(true);
- UpdateTimeStamp(op);
+ op.mutable_response()->PackFrom(execute_response);
+ op.set_done(true);
+ UpdateTimeStamp(&op);
- op_cache_.Set(op->name(), *op);
- writer->Write(*op);
+ op_cache_.Set(op.name(), op);
+ writer->Write(op);
}
auto ExecutionServiceImpl::Execute(
@@ -223,7 +223,7 @@ auto ExecutionServiceImpl::Execute(
}
}
- WriteResponse(*execute_response, writer, &op);
+ WriteResponse(*execute_response, writer, std::move(op));
return ::grpc::Status::OK;
}