/*
* @Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved.
*/
package mqtt4cj.mqttv3
/**
* A high-resolution timer source.
*
* Implementations must use clocks that are guaranteed to be monotonic and continue to run
* even if the CPU enters a low-power state.
*/
public interface HighResolutionTimer {
/**
* Returns the current value of a high-resolution time source, in nanoseconds.
*
* This method can only be used to measure elapsed time and may return negative values.
*
* @return the current value of a high-resolution time source, in nanoseconds.
*/
func duration(): Duration
}
class SystemHighResolutionTimer <: HighResolutionTimer {
public func duration(): Duration {
return DateTime.now().toUnixTimeStamp()
}
}