// Copyright 2019 The MediaPipe Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "mediapipe/framework/deps/monotonic_clock.h" #include "absl/base/macros.h" #include "absl/base/thread_annotations.h" #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/synchronization/mutex.h" #include "absl/time/time.h" namespace mediapipe { // This state, which contains the "guts" of MonotonicClockImpl, is separate // from the class instance so that it can be shared to implement a // SynchronizedMonotonicClock. (The per-instance state of MonotonicClock is // just for frills like the correction metrics and callback.) It lives in this // private namespace so that test code can use it without exposing it to the // world. struct MonotonicClock::State { … }; State; class MonotonicClockImpl : public MonotonicClock { … }; // Factory methods. MonotonicClock* MonotonicClock::CreateMonotonicClock(Clock* clock) { … } namespace { State* GlobalSyncState() { … } } // namespace // The reason that SynchronizedMonotonicClock is not implemented as a singleton // is so that different code bases can handle clock corrections their own way. MonotonicClock* MonotonicClock::CreateSynchronizedMonotonicClock() { … } // Test access methods. void MonotonicClockAccess::SynchronizedMonotonicClockReset() { … } State* MonotonicClockAccess::CreateMonotonicClockState(Clock* raw_clock) { … } void MonotonicClockAccess::DeleteMonotonicClockState(State* state) { … } MonotonicClock* MonotonicClockAccess::CreateMonotonicClock(State* state) { … } } // namespace mediapipe