Package io.deephaven.base.clock
Interface SystemClock
- All Superinterfaces:
Clock
- All Known Implementing Classes:
SystemClockMillis
,SystemClockUtc
A marker interface for
Clock
that designates implementations as system clocks.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SystemClock
of()
Creates a new system clock, or returns the singleton instance, based on system property "deephaven.systemClock" (uses "default" if not present).static Optional<SystemClock>
UsesServiceLoader.load(Class)
withSystemClock.class
to load a system clock.static SystemClock
The system clock, based off ofSystem.currentTimeMillis()
.static SystemClock
The system clock, based off ofClock.systemUTC()
.Methods inherited from interface io.deephaven.base.clock.Clock
currentTimeMicros, currentTimeMillis, currentTimeNanos, instantMillis, instantNanos
-
Field Details
-
KEY
- See Also:
-
DEFAULT
- See Also:
-
SERVICE_LOADER
- See Also:
-
SYSTEM_UTC
- See Also:
-
SYSTEM_MILLIS
- See Also:
-
-
Method Details
-
of
static SystemClock of() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessExceptionCreates a new system clock, or returns the singleton instance, based on system property "deephaven.systemClock" (uses "default" if not present).Property Value Logic "default" serviceLoader().orElse(systemUTC())
"serviceLoader" serviceLoader().orElseThrow()
"systemUTC" systemUTC()
"systemMillis" systemMillis()
value (SystemClock) Class.forName(value).getDeclaredConstructor().newInstance()
- Returns:
- a new instance of the system clock
- Throws:
ClassNotFoundException
NoSuchMethodException
InvocationTargetException
InstantiationException
IllegalAccessException
- See Also:
-
systemUTC
The system clock, based off ofClock.systemUTC()
.- Returns:
- the system clock
- See Also:
-
systemMillis
The system clock, based off ofSystem.currentTimeMillis()
.- Returns:
- the millis-based system clock
- See Also:
-
serviceLoader
UsesServiceLoader.load(Class)
withSystemClock.class
to load a system clock.If a
ServiceConfigurationError
is thrown, the error will be logged toSystem.err
andOptional.empty()
will be returned.- Returns:
- the service loader system clock
- Throws:
IllegalStateException
- if more than one system clock is registered
-