25 #ifndef ABSL_SYNCHRONIZATION_INTERNAL_KERNEL_TIMEOUT_H_ 26 #define ABSL_SYNCHRONIZATION_INTERNAL_KERNEL_TIMEOUT_H_ 37 namespace synchronization_internal {
80 if (x == (std::numeric_limits<int64_t>::max)()) x = 0;
88 static const int64_t kNanosPerSecond = 1000 * 1000 * 1000;
92 "Tried to create a timespec from a non-timeout; never do this.");
94 n = (std::numeric_limits<int64_t>::max)();
103 struct timespec abstime;
104 int64_t
seconds = (std::min)(n / kNanosPerSecond,
105 int64_t{(std::numeric_limits<time_t>::max)()});
106 abstime.tv_sec =
static_cast<time_t
>(
seconds);
108 static_cast<decltype(abstime.tv_nsec)
>(n % kNanosPerSecond);
121 typedef unsigned long DWord;
122 DWord InMillisecondsFromNow()
const {
123 constexpr DWord kInfinite = (std::numeric_limits<DWord>::max)();
133 constexpr uint64_t max_nanos =
134 (std::numeric_limits<int64_t>::max)() - 999999u;
135 uint64_t ms_from_now =
136 (std::min<uint64_t>(max_nanos, ns_ - now) + 999999u) / 1000000u;
137 if (ms_from_now > kInfinite) {
140 return static_cast<DWord
>(ms_from_now);
153 #endif // ABSL_SYNCHRONIZATION_INTERNAL_KERNEL_TIMEOUT_H_ constexpr Time InfiniteFuture()
static int64_t MakeNs(absl::Time t)
#define ABSL_RAW_LOG(severity,...)
static KernelTimeout Never()
std::chrono::duration< std::int_fast64_t > seconds
struct timespec MakeAbsTimespec()
int64_t ToUnixNanos(Time t)
KernelTimeout(absl::Time t)