Package com.biglybt.core.util
Class SystemTime
- java.lang.Object
-
- com.biglybt.core.util.SystemTime
-
public class SystemTime extends java.lang.Object
Utility class to retrieve current system time, and catch clock backward time changes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SystemTime.ChangeListener
private static class
SystemTime.RawProvider
private static class
SystemTime.SteppedProvider
protected static interface
SystemTime.SystemTimeProvider
static interface
SystemTime.TickConsumer
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<SystemTime.ChangeListener>
clock_change_list
private static SystemTime.SystemTimeProvider
instance
private static java.util.List<SystemTime.TickConsumer>
monotoneTimeConsumers
private static boolean
SOD_IT_LETS_USE_HPC
private static int
STEPS_PER_SECOND
private static java.util.List<SystemTime.TickConsumer>
systemTimeConsumers
static long
TIME_GRANULARITY_MILLIS
-
Constructor Summary
Constructors Constructor Description SystemTime()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
getCurrentTime()
Note that this can this time can jump into the future or past due to clock adjustments use getMonotonousTime() if you need steady increasesstatic long
getHighPrecisionCounter()
static long
getMonotonousTime()
Time that is guaranteed to grow monotonously and also ignores larger jumps into the future which might be caused by adjusting the system clock
Do not mix times retrieved by this method with normal time!static long
getOffsetTime(long offsetMS)
static long
getSteppedMonotonousTime()
Like getMonotonousTime but only updated at TIME_GRANULARITY_MILLIS intervals (not interpolated) As such it is likely to be cheaper to obtainstatic void
main(java.lang.String[] args)
static void
registerClockChangeListener(SystemTime.ChangeListener c)
static void
registerConsumer(SystemTime.TickConsumer c)
static void
registerMonotonousConsumer(SystemTime.TickConsumer c)
static void
unregisterClockChangeListener(SystemTime.ChangeListener c)
static void
unregisterConsumer(SystemTime.TickConsumer c)
static void
unregisterMonotonousConsumer(SystemTime.TickConsumer c)
static void
useRawProvider()
-
-
-
Field Detail
-
TIME_GRANULARITY_MILLIS
public static final long TIME_GRANULARITY_MILLIS
- See Also:
- Constant Field Values
-
STEPS_PER_SECOND
private static final int STEPS_PER_SECOND
- See Also:
- Constant Field Values
-
instance
private static SystemTime.SystemTimeProvider instance
-
SOD_IT_LETS_USE_HPC
private static final boolean SOD_IT_LETS_USE_HPC
- See Also:
- Constant Field Values
-
systemTimeConsumers
private static volatile java.util.List<SystemTime.TickConsumer> systemTimeConsumers
-
monotoneTimeConsumers
private static volatile java.util.List<SystemTime.TickConsumer> monotoneTimeConsumers
-
clock_change_list
private static volatile java.util.List<SystemTime.ChangeListener> clock_change_list
-
-
Method Detail
-
useRawProvider
public static void useRawProvider()
-
getCurrentTime
public static long getCurrentTime()
Note that this can this time can jump into the future or past due to clock adjustments use getMonotonousTime() if you need steady increases- Returns:
- current system time in millisecond since epoch
-
getMonotonousTime
public static long getMonotonousTime()
Time that is guaranteed to grow monotonously and also ignores larger jumps into the future which might be caused by adjusting the system clock
Do not mix times retrieved by this method with normal time!- Returns:
- the amount of real time passed since the program start in milliseconds
-
getSteppedMonotonousTime
public static long getSteppedMonotonousTime()
Like getMonotonousTime but only updated at TIME_GRANULARITY_MILLIS intervals (not interpolated) As such it is likely to be cheaper to obtain- Returns:
-
getOffsetTime
public static long getOffsetTime(long offsetMS)
-
registerConsumer
public static void registerConsumer(SystemTime.TickConsumer c)
-
unregisterConsumer
public static void unregisterConsumer(SystemTime.TickConsumer c)
-
registerMonotonousConsumer
public static void registerMonotonousConsumer(SystemTime.TickConsumer c)
-
unregisterMonotonousConsumer
public static void unregisterMonotonousConsumer(SystemTime.TickConsumer c)
-
registerClockChangeListener
public static void registerClockChangeListener(SystemTime.ChangeListener c)
-
unregisterClockChangeListener
public static void unregisterClockChangeListener(SystemTime.ChangeListener c)
-
getHighPrecisionCounter
public static long getHighPrecisionCounter()
-
main
public static void main(java.lang.String[] args)
-
-