chromium/third_party/mediapipe/src/mediapipe/framework/deps/monotonic_clock.h

// 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.

#ifndef MEDIAPIPE_DEPS_MONOTONIC_CLOCK_H_
#define MEDIAPIPE_DEPS_MONOTONIC_CLOCK_H_

#include "absl/time/time.h"
#include "mediapipe/framework/deps/clock.h"

namespace mediapipe {

// MonotonicClock is an interface for a Clock that never goes backward.
// Successive returned values from Now() are guaranteed to be monotonically
// non-decreasing, although they may not be monotonic with respect to values
// returned from other instances of MonotonicClock.
//
// You can wrap any Clock object in a MonotonicClock using the
// CreateMonotonicClock() factory method, including Clock::RealClock().
// However, if you want a monotonic version of real time, it is strongly
// recommended that you use the CreateSynchronizedMonotonicClock() factory
// method, which wraps Clock::RealClock() and guarantees that values returned
// from Now() are monotonic ACROSS instances of the class that are created by
// CreateSynchronizedMonotonicClock().
//
// All methods support concurrent access.
class MonotonicClock : public Clock {};

class MonotonicClockTest;

// Provides access to MonotonicClock::State for unit-testing.
class MonotonicClockAccess {};

}  // namespace mediapipe

#endif  // MEDIAPIPE_DEPS_MONOTONIC_CLOCK_H_