Class DefaultLongTaskTimer

    • Constructor Detail

      • DefaultLongTaskTimer

        public DefaultLongTaskTimer​(Meter.Id id,
                                    Clock clock)
    • Method Detail

      • start

        public LongTaskTimer.Sample start()
        Description copied from interface: LongTaskTimer
        Start keeping time for a task.
        Specified by:
        start in interface LongTaskTimer
        Returns:
        A task id that can be used to look up how long the task has been running.
      • stop

        public long stop​(long task)
        Description copied from interface: LongTaskTimer
        Mark a given task as completed.
        Specified by:
        stop in interface LongTaskTimer
        Parameters:
        task - Id for the task to stop. This should be the value returned from LongTaskTimer.start().
        Returns:
        Duration for the task in nanoseconds. A -1 value will be returned for an unknown task.
      • duration

        public double duration​(long task,
                               java.util.concurrent.TimeUnit unit)
        Description copied from interface: LongTaskTimer
        The current duration for an active task.
        Specified by:
        duration in interface LongTaskTimer
        Parameters:
        task - Id for the task to stop. This should be the value returned from LongTaskTimer.start().
        unit - The time unit to scale the duration to.
        Returns:
        Duration for the task. A -1 value will be returned for an unknown task.
      • duration

        public double duration​(java.util.concurrent.TimeUnit unit)
        Specified by:
        duration in interface LongTaskTimer
        Parameters:
        unit - The time unit to scale the duration to.
        Returns:
        The cumulative duration of all current tasks.
      • activeTasks

        public int activeTasks()
        Specified by:
        activeTasks in interface LongTaskTimer
        Returns:
        The current number of tasks being executed.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object