001/*
002 * Copyright 2023 the original author or authors.
003 * <p>
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * <p>
008 * https://www.apache.org/licenses/LICENSE-2.0
009 * <p>
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package de.cuioss.tools.concurrent;
017
018import java.io.Serializable;
019
020/**
021 * A time source; returns a time value representing the number of nanoseconds
022 * elapsed since some fixed but arbitrary point in time. Note that most users
023 * should use {@link StopWatch} instead of interacting with this class directly.
024 *
025 * <p>
026 * <b>Warning:</b> this type can only be used to measure elapsed time, not wall
027 * time.
028 *
029 * @author com.google.common.base.Ticker
030 */
031public class Ticker implements Serializable {
032
033    private static final long serialVersionUID = -1361587646696392654L;
034
035    /**
036     * @return the number of nanoseconds elapsed since this ticker's fixed point of
037     *         reference.
038     */
039    public long read() {
040        return System.nanoTime();
041    }
042}