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 long
currentTimeMillis()
long
nanoTime()
TimeSource
sleep(long sleepFor, java.util.concurrent.TimeUnit unit)
Sleep for the given amount of time.TimeSource
sleepUninterruptibly(long sleepFor, java.util.concurrent.TimeUnit unit)
Sleep for the given amount of time uninterruptibly.
-
-
-
Method Detail
-
currentTimeMillis
public long currentTimeMillis()
- Specified by:
currentTimeMillis
in interfaceTimeSource
- Returns:
- the current time in milliseconds
-
nanoTime
public long nanoTime()
- Specified by:
nanoTime
in 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:TimeSource
Sleep for the given amount of time uninterruptibly.- Specified by:
sleepUninterruptibly
in 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:TimeSource
Sleep 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:
sleep
in interfaceTimeSource
- Parameters:
sleepFor
- given amout.unit
- time unit- Returns:
- The time source itself after the given sleep period.
- Throws:
java.lang.InterruptedException
-
-