Package org.infinispan.commons.time
Interface TimeService
- All Known Implementing Classes:
DefaultTimeService
,EmbeddedTimeService
public interface TimeService
Encapsulates all the time related logic in this interface.
- Since:
- 5.3
- Author:
- Pedro Ruivo
-
Method Summary
Modifier and TypeMethodDescriptionlong
expectedEndTime
(long duration, TimeUnit inputTimeUnit) instant()
boolean
isTimeExpired
(long endTimeNanos) long
remainingTime
(long endTimeNanos, TimeUnit outputTimeUnit) long
time()
long
timeDuration
(long startTimeNanos, long endTimeNanos, TimeUnit outputTimeUnit) long
timeDuration
(long startTimeNanos, TimeUnit outputTimeUnit) It is equivalent totimeDuration(startTime, time(), outputTimeUnit)
.long
-
Method Details
-
wallClockTime
long wallClockTime()- Returns:
- the current clock time in milliseconds. Note that it depends of the system time.
-
time
long time()- Returns:
- the current cpu time in nanoseconds. Note that some platforms do not provide nanosecond precision.
-
instant
Instant instant() -
timeDuration
It is equivalent totimeDuration(startTime, time(), outputTimeUnit)
.- Parameters:
startTimeNanos
- start cpu time in nanoseconds, usually returned bytime()
.outputTimeUnit
- theTimeUnit
of the returned value.- Returns:
- the duration between the current cpu time and startTime. It returns zero if startTime is less than zero or if startTime is greater than the current cpu time.
-
timeDuration
- Parameters:
startTimeNanos
- start cpu time in nanoseconds, usually returned bytime()
.endTimeNanos
- end cpu time in nanoseconds, usually returned bytime()
.outputTimeUnit
- theTimeUnit
of the returned value.- Returns:
- the duration between the endTime and startTime. It returns zero if startTime or endTime are less than zero or if startTime is greater than the endTime.
-
isTimeExpired
boolean isTimeExpired(long endTimeNanos) - Parameters:
endTimeNanos
- a cpu time in nanoseconds, usually returned bytime()
- Returns:
true
if the endTime is less or equals than the current cpu time.
-
remainingTime
- Parameters:
endTimeNanos
- the end cpu time in nanoseconds.outputTimeUnit
- theTimeUnit
of the returned value.- Returns:
- the remaining cpu time until the endTime is reached.
-
expectedEndTime
-