Fixed a data race bug in test codes

PiperOrigin-RevId: 528074883
This commit is contained in:
Guogang Li
2023-04-28 22:25:09 -07:00
committed by Copybara-Service
parent 10174f8a47
commit 46e4b3eca7
2 changed files with 6 additions and 0 deletions
+5
View File
@@ -21,6 +21,11 @@
namespace nearby {
FakeClock::~FakeClock() {
absl::MutexLock lock(&mutex_);
observers_.clear();
}
absl::Time FakeClock::Now() const {
absl::MutexLock lock(&mutex_);
return now_;
+1
View File
@@ -33,6 +33,7 @@ class FakeClock : public Clock {
FakeClock() { now_ = absl::Now(); }
FakeClock(FakeClock&&) = default;
FakeClock& operator=(FakeClock&&) = default;
~FakeClock() override ABSL_LOCKS_EXCLUDED(mutex_);
absl::Time Now() const override;