Finish off SystemClock

PiperOrigin-RevId: 396369189
This commit is contained in:
jfcarroll
2021-09-13 09:07:16 -07:00
committed by Copybara-Service
parent e4a3da97d1
commit 1a3b294407
2 changed files with 15 additions and 8 deletions
+1 -1
View File
@@ -17,7 +17,6 @@ cc_library(
name = "types",
srcs = [
"log_message.cc",
"system_clock.cc",
],
hdrs = [
"atomic_boolean.h",
@@ -108,6 +107,7 @@ cc_library(
"platform.cc",
"scheduled_executor.cc",
"submittable_executor.cc",
"system_clock.cc",
"thread_pool.cc",
"utils.cc",
],
+14 -7
View File
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -21,14 +21,21 @@ namespace location {
namespace nearby {
// Initialize global system state.
// TODO(b/184975123): replace with real implementation.
void SystemClock::Init() {}
void SystemClock::Init() { }
// Returns current absolute time. It is guaranteed to be monotonic.
// TODO(b/184975123): replace with real implementation.
absl::Time SystemClock::ElapsedRealtime() { return absl::UnixEpoch(); }
absl::Time SystemClock::ElapsedRealtime() {
return absl::FromUnixNanos(
std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::steady_clock::now().time_since_epoch())
.count());
}
// Pauses current thread for the specified duration.
// TODO(b/184975123): replace with real implementation.
Exception SystemClock::Sleep(absl::Duration duration) { return Exception{}; }
Exception SystemClock::Sleep(absl::Duration duration) {
absl::SleepFor(duration);
return {Exception::kSuccess};
}
} // namespace nearby
} // namespace location