• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 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 #include <grpc/support/port_platform.h>
15 
16 #include "src/core/lib/event_engine/utils.h"
17 
18 #include <stdint.h>
19 
20 #include <algorithm>
21 
22 #include "absl/strings/str_cat.h"
23 
24 #include <grpc/event_engine/event_engine.h>
25 
26 #include "src/core/lib/gprpp/time.h"
27 
28 namespace grpc_event_engine {
29 namespace experimental {
30 
HandleToStringInternal(uintptr_t a,uintptr_t b)31 std::string HandleToStringInternal(uintptr_t a, uintptr_t b) {
32   return absl::StrCat("{", absl::Hex(a, absl::kZeroPad16), ",",
33                       absl::Hex(b, absl::kZeroPad16), "}");
34 }
35 
ToTimestamp(grpc_core::Timestamp now,EventEngine::Duration delta)36 grpc_core::Timestamp ToTimestamp(grpc_core::Timestamp now,
37                                  EventEngine::Duration delta) {
38   return now +
39          std::max(grpc_core::Duration::Milliseconds(1),
40                   grpc_core::Duration::NanosecondsRoundUp(delta.count())) +
41          grpc_core::Duration::Milliseconds(1);
42 }
43 
44 }  // namespace experimental
45 }  // namespace grpc_event_engine
46