diff options
author | Derek Mauro <dmauro@google.com> | 2023-04-12 13:26:48 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-04-12 13:27:28 -0700 |
commit | c23acb9b5636e7b908fba03d6b3584d8f80dba6d (patch) | |
tree | cc2332512cecd0d3efb2f3819516fb6d7af44bc6 /absl/synchronization/internal/kernel_timeout.cc | |
parent | 32d314d0f5bb0ca3ff71ece49c71a728c128d43e (diff) | |
download | abseil-c23acb9b5636e7b908fba03d6b3584d8f80dba6d.tar.gz abseil-c23acb9b5636e7b908fba03d6b3584d8f80dba6d.tar.bz2 abseil-c23acb9b5636e7b908fba03d6b3584d8f80dba6d.zip |
Synchronization: Consolidate the logic for whether steady clocks are supported
for relative timeouts
PiperOrigin-RevId: 523789416
Change-Id: Ide4cfdcae9ea7bffca3355c80ea9c8833a9536e6
Diffstat (limited to 'absl/synchronization/internal/kernel_timeout.cc')
-rw-r--r-- | absl/synchronization/internal/kernel_timeout.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/absl/synchronization/internal/kernel_timeout.cc b/absl/synchronization/internal/kernel_timeout.cc index bfbf282f..48ea6287 100644 --- a/absl/synchronization/internal/kernel_timeout.cc +++ b/absl/synchronization/internal/kernel_timeout.cc @@ -21,9 +21,13 @@ #include <algorithm> #include <chrono> // NOLINT(build/c++11) #include <cstdint> +#include <cstdlib> +#include <cstring> #include <ctime> #include <limits> +#include "absl/base/attributes.h" +#include "absl/base/call_once.h" #include "absl/base/config.h" #include "absl/time/time.h" @@ -37,15 +41,12 @@ constexpr int64_t KernelTimeout::kMaxNanos; #endif int64_t KernelTimeout::SteadyClockNow() { -#ifdef __GOOGLE_GRTE_VERSION__ - // go/btm requires synchronized clocks, so we have to use the system - // clock. - return absl::GetCurrentTimeNanos(); -#else + if (!SupportsSteadyClock()) { + return absl::GetCurrentTimeNanos(); + } return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::steady_clock::now().time_since_epoch()) .count(); -#endif } KernelTimeout::KernelTimeout(absl::Time t) { |