summaryrefslogtreecommitdiff
path: root/absl/synchronization
diff options
context:
space:
mode:
authorGravatar Derek Mauro <dmauro@google.com>2023-02-15 07:40:18 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-02-15 07:41:08 -0800
commitb54044578175b6949fb151b4d8be9153d7093c31 (patch)
tree414936f548907ab15cc20ec9800928591dc76b44 /absl/synchronization
parent8aa88cd11caa8dbfd5966e5e2f391b892cfd1c35 (diff)
KernelTimeout optimization: Use absl::GetCurrentTimeNanos()
instead of absl::ToUnixNanos(absl::Now()); PiperOrigin-RevId: 509829866 Change-Id: Ib34362762304ad6eb7980a1227d717069b84f656
Diffstat (limited to 'absl/synchronization')
-rw-r--r--absl/synchronization/internal/kernel_timeout.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/absl/synchronization/internal/kernel_timeout.cc b/absl/synchronization/internal/kernel_timeout.cc
index 4015bd0c..8d9e7d74 100644
--- a/absl/synchronization/internal/kernel_timeout.cc
+++ b/absl/synchronization/internal/kernel_timeout.cc
@@ -89,7 +89,7 @@ int64_t KernelTimeout::MakeAbsNanos() const {
int64_t nanos = RawNanos();
if (is_relative_timeout()) {
- int64_t now = ToUnixNanos(absl::Now());
+ int64_t now = absl::GetCurrentTimeNanos();
if (nanos > kMaxNanos - now) {
// Overflow.
nanos = kMaxNanos;
@@ -118,7 +118,7 @@ struct timespec KernelTimeout::MakeRelativeTimespec() const {
}
int64_t nanos = RawNanos();
- int64_t now = ToUnixNanos(absl::Now());
+ int64_t now = absl::GetCurrentTimeNanos();
if (now > nanos) {
// Convert past values to 0 to be safe.
nanos = 0;
@@ -146,7 +146,7 @@ KernelTimeout::DWord KernelTimeout::InMillisecondsFromNow() const {
return static_cast<DWord>(ms);
}
- int64_t now = ToUnixNanos(absl::Now());
+ int64_t now = absl::GetCurrentTimeNanos();
if (nanos >= now) {
// Round up so that now + ms_from_now >= nanos.
constexpr uint64_t kMaxValueNanos =