public enum Sleep extends Enum<Sleep>
TimeUnit
's sleep functionality.
Use these methods rather than Thread.sleep(long)
or TimeUnit.sleep(long)
because they handle properly.Enum Constant and Description |
---|
DAYS |
HOURS |
MICROSECONDS |
MILLISECONDS |
MINUTES |
NANOSECONDS |
SECONDS |
Modifier and Type | Method and Description |
---|---|
void |
sleepRecoverably(long duration)
Sleep, throwing an
InterruptedException
if the sleep is interrupted, re-setting the interrupted flag. |
static void |
sleepUninterruptibly(Duration duration)
Sleep, without recovery logic in case the sleep is interrupted.
|
void |
sleepUninterruptibly(long duration)
Sleep, without recovery logic in case the sleep is interrupted.
|
static Sleep |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Sleep[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Sleep NANOSECONDS
public static final Sleep MICROSECONDS
public static final Sleep MILLISECONDS
public static final Sleep SECONDS
public static final Sleep MINUTES
public static final Sleep HOURS
public static final Sleep DAYS
public static Sleep[] values()
for (Sleep c : Sleep.values()) System.out.println(c);
public static Sleep valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static void sleepUninterruptibly(Duration duration)
If sleep is interrupted, this method will throw
UnrecoverableCorfuInterruptedError
, which will indicate that Corfu was interrupted
but cannot recover from the interruption.
duration
- The duration to sleep.public void sleepUninterruptibly(long duration)
If sleep is interrupted, this method will throw
UnrecoverableCorfuInterruptedError
, which will indicate that Corfu was interrupted
but cannot recover from the interruption.
duration
- The duration to sleep.public void sleepRecoverably(long duration) throws InterruptedException
InterruptedException
if the sleep is interrupted, re-setting the interrupted flag. If you call this method,
you should cleanup state and exit the method you are currently running in, returning to
the caller, by rethrowing the exception.duration
- The duration to sleep.InterruptedException
Copyright © 2019 CorfuDB. All rights reserved.