Package org.apache.cassandra.utils
Class SystemTimeSource
- java.lang.Object
-
- org.apache.cassandra.utils.SystemTimeSource
-
- All Implemented Interfaces:
TimeSource
public class SystemTimeSource extends java.lang.Object implements TimeSource
Time source backed by JVM clock.
-
-
Constructor Summary
Constructors Constructor Description SystemTimeSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcurrentTimeMillis()longnanoTime()TimeSourcesleep(long sleepFor, java.util.concurrent.TimeUnit unit)Sleep for the given amount of time.TimeSourcesleepUninterruptibly(long sleepFor, java.util.concurrent.TimeUnit unit)Sleep for the given amount of time uninterruptibly.
-
-
-
Method Detail
-
currentTimeMillis
public long currentTimeMillis()
- Specified by:
currentTimeMillisin interfaceTimeSource- Returns:
- the current time in milliseconds
-
nanoTime
public long nanoTime()
- Specified by:
nanoTimein interfaceTimeSource- Returns:
- Returns the current time value in nanoseconds.
This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time.
-
sleepUninterruptibly
public TimeSource sleepUninterruptibly(long sleepFor, java.util.concurrent.TimeUnit unit)
Description copied from interface:TimeSourceSleep for the given amount of time uninterruptibly.- Specified by:
sleepUninterruptiblyin interfaceTimeSource- Parameters:
sleepFor- given amout.unit- time unit- Returns:
- The time source itself after the given sleep period.
-
sleep
public TimeSource sleep(long sleepFor, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Description copied from interface:TimeSourceSleep for the given amount of time. This operation could interrupted. Hence after returning from this method, it is not guaranteed that the request amount of time has passed.- Specified by:
sleepin interfaceTimeSource- Parameters:
sleepFor- given amout.unit- time unit- Returns:
- The time source itself after the given sleep period.
- Throws:
java.lang.InterruptedException
-
-