include/grpcpp/impl/codegen/time.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPCPP_IMPL_CODEGEN_TIME_H
20 #define GRPCPP_IMPL_CODEGEN_TIME_H
21 
22 // IWYU pragma: private, include <grpcpp/support/time.h>
23 
24 #include <chrono>
25 
28 
29 namespace grpc {
30 
41 template <typename T>
42 class TimePoint {
43  public:
44  // If you see the error with methods below, you may need either
45  // i) using the existing types having a conversion class such as
46  // gpr_timespec and std::chrono::system_clock::time_point or
47  // ii) writing a new TimePoint<YourType> to address your case.
48  TimePoint(const T& /*time*/) = delete;
49  gpr_timespec raw_time() = delete;
50 };
51 
52 template <>
54  public:
55  /* NOLINTNEXTLINE(google-explicit-constructor) */
56  TimePoint(const gpr_timespec& time) : time_(time) {}
57  gpr_timespec raw_time() { return time_; }
58 
59  private:
61 };
62 
63 } // namespace grpc
64 
65 namespace grpc {
66 
67 // from and to should be absolute time.
69  gpr_timespec* to);
72  gpr_timespec* to);
73 
75 
76 template <>
78  public:
79  /* NOLINTNEXTLINE(google-explicit-constructor) */
81  Timepoint2Timespec(time, &time_);
82  }
83  gpr_timespec raw_time() const { return time_; }
84 
85  private:
87 };
88 
89 } // namespace grpc
90 
91 #endif // GRPCPP_IMPL_CODEGEN_TIME_H
grpc
Definition: grpcpp/alarm.h:33
absl::time_internal::cctz::time_point
std::chrono::time_point< std::chrono::system_clock, D > time_point
Definition: abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h:39
grpc::TimePoint< std::chrono::system_clock::time_point >::raw_time
gpr_timespec raw_time() const
Definition: include/grpcpp/impl/codegen/time.h:83
grpc::TimePoint< gpr_timespec >::raw_time
gpr_timespec raw_time()
Definition: include/grpcpp/impl/codegen/time.h:57
grpc::TimePoint< gpr_timespec >::time_
gpr_timespec time_
Definition: include/grpcpp/impl/codegen/time.h:60
to
size_t to
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1385
grpc::TimePoint
Definition: include/grpcpp/impl/codegen/time.h:42
T
#define T(upbtypeconst, upbtype, ctype, default_value)
config.h
grpc_types.h
from
size_t from
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1384
grpc::TimePoint::TimePoint
TimePoint(const T &)=delete
grpc::TimePoint< std::chrono::system_clock::time_point >::TimePoint
TimePoint(const std::chrono::system_clock::time_point &time)
Definition: include/grpcpp/impl/codegen/time.h:80
grpc::Timespec2Timepoint
std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t)
Definition: time_cc.cc:68
grpc::TimePoint< std::chrono::system_clock::time_point >::time_
gpr_timespec time_
Definition: include/grpcpp/impl/codegen/time.h:86
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
grpc::TimePoint< gpr_timespec >::TimePoint
TimePoint(const gpr_timespec &time)
Definition: include/grpcpp/impl/codegen/time.h:56
grpc::Timepoint2Timespec
void Timepoint2Timespec(const std::chrono::system_clock::time_point &from, gpr_timespec *to)
grpc::TimepointHR2Timespec
void TimepointHR2Timespec(const std::chrono::high_resolution_clock::time_point &from, gpr_timespec *to)
gpr_timespec
Definition: gpr_types.h:50
grpc::TimePoint::raw_time
gpr_timespec raw_time()=delete


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:37