1 // Copyright 2024 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include <grpc/support/port_platform.h>
16
17 #include "src/core/lib/transport/call_final_info.h"
18
19 #include <utility>
20
move64bits(uint64_t * from,uint64_t * to)21 static void move64bits(uint64_t* from, uint64_t* to) {
22 *to += *from;
23 *from = 0;
24 }
25
grpc_transport_move_one_way_stats(grpc_transport_one_way_stats * from,grpc_transport_one_way_stats * to)26 void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from,
27 grpc_transport_one_way_stats* to) {
28 move64bits(&from->framing_bytes, &to->framing_bytes);
29 move64bits(&from->data_bytes, &to->data_bytes);
30 move64bits(&from->header_bytes, &to->header_bytes);
31 }
32
grpc_transport_move_stats(grpc_transport_stream_stats * from,grpc_transport_stream_stats * to)33 void grpc_transport_move_stats(grpc_transport_stream_stats* from,
34 grpc_transport_stream_stats* to) {
35 grpc_transport_move_one_way_stats(&from->incoming, &to->incoming);
36 grpc_transport_move_one_way_stats(&from->outgoing, &to->outgoing);
37 to->latency = std::exchange(from->latency, gpr_inf_future(GPR_TIMESPAN));
38 }
39