Constructor and Description |
---|
WaitForAsyncUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> Future<T> |
async(Callable<T> callable)
|
static Future<Void> |
async(Runnable runnable)
|
static <T> Future<T> |
asyncFx(Callable<T> callable)
|
static Future<Void> |
asyncFx(Runnable runnable)
|
static void |
sleep(long duration,
TimeUnit timeUnit)
Sleeps the given duration.
|
static <T> T |
waitFor(Future<T> future)
Waits for given
Future to be set (push) and returns T . |
static void |
waitFor(long timeout,
TimeUnit timeUnit,
Callable<Boolean> condition)
Waits for given condition
Callable to return (pull) true , otherwise times
out with TimeoutException . |
static <T> T |
waitFor(long timeout,
TimeUnit timeUnit,
Future<T> future)
|
static void |
waitFor(long timeout,
TimeUnit timeUnit,
ObservableBooleanValue booleanValue)
Waits for given observable
ObservableBooleanValue to return (push) true ,
otherwise times out with TimeoutException . |
static <T> T |
waitForAsync(long millis,
Callable<T> callable)
Calls the given
Callable on a new Thread , waits for it long
milliseconds to finish and returns T , otherwise times out with
TimeoutException . |
static void |
waitForAsync(long millis,
Runnable runnable)
Runs the given
Runnable on a new Thread and waits for it long
milliseconds to finish, otherwise times out with TimeoutException . |
static <T> T |
waitForAsyncFx(long millis,
Callable<T> callable)
Calls the given
Callable on the JavaFX Application Thread at some unspecified time
in the future, waits for it long milliseconds to finish and returns T ,
otherwise times out with TimeoutException . |
static void |
waitForAsyncFx(long millis,
Runnable runnable)
Runs the given
Runnable on the JavaFX Application Thread at some unspecified time
in the future and waits for it long milliseconds to finish, otherwise times out with
TimeoutException . |
static void |
waitForFxEvents()
Waits for the event queue of JavaFX Application Thread to be completed, as well as any new
events triggered in it.
|
static void |
waitForFxEvents(int attemptsCount)
Waits the given
int attempts for the event queue of JavaFX Application Thread to be
completed, as well as any new events triggered on it. |
public static Future<Void> async(Runnable runnable)
runnable
- the runnablepublic static <T> Future<T> async(Callable<T> callable)
T
- the callable typecallable
- the callablepublic static Future<Void> asyncFx(Runnable runnable)
Runnable
on the JavaFX Application Thread at some unspecified time
in the future and returns a Future
that is set on finish or error.runnable
- the runnablepublic static <T> Future<T> asyncFx(Callable<T> callable)
Callable
on the JavaFX Application Thread at some unspecified time
in the future and returns a Future
that is set on finish or error.T
- the callable typecallable
- the callablepublic static <T> T waitFor(Future<T> future)
Future
to be set (push) and returns T
.T
- the future typefuture
- the futurepublic static <T> T waitFor(long timeout, TimeUnit timeUnit, Future<T> future) throws TimeoutException
T
- the future typetimeout
- the timeouttimeUnit
- the time unitfuture
- the futureTimeoutException
public static void waitFor(long timeout, TimeUnit timeUnit, Callable<Boolean> condition) throws TimeoutException
Callable
to return (pull) true
, otherwise times
out with TimeoutException
. The condition will be evaluated at least once. The method
will wait for the last condition to finish after a timeout.timeout
- the timeouttimeUnit
- the time unitcondition
- the conditionTimeoutException
public static void waitFor(long timeout, TimeUnit timeUnit, ObservableBooleanValue booleanValue) throws TimeoutException
ObservableBooleanValue
to return (push) true
,
otherwise times out with TimeoutException
.timeout
- the timeouttimeUnit
- the time unitbooleanValue
- the observableTimeoutException
public static void waitForFxEvents()
public static void waitForFxEvents(int attemptsCount)
int
attempts for the event queue of JavaFX Application Thread to be
completed, as well as any new events triggered on it.attemptsCount
- the attemptspublic static void sleep(long duration, TimeUnit timeUnit)
duration
- the durationtimeUnit
- the time unitpublic static void waitForAsync(long millis, Runnable runnable)
Runnable
on a new Thread
and waits for it long
milliseconds to finish, otherwise times out with TimeoutException
.millis
- the millisecondsrunnable
- the runnablepublic static <T> T waitForAsync(long millis, Callable<T> callable)
Callable
on a new Thread
, waits for it long
milliseconds to finish and returns T
, otherwise times out with
TimeoutException
.T
- the callable typemillis
- the millisecondscallable
- the callablepublic static void waitForAsyncFx(long millis, Runnable runnable)
Runnable
on the JavaFX Application Thread at some unspecified time
in the future and waits for it long
milliseconds to finish, otherwise times out with
TimeoutException
.millis
- the millisecondsrunnable
- the runnablepublic static <T> T waitForAsyncFx(long millis, Callable<T> callable)
Callable
on the JavaFX Application Thread at some unspecified time
in the future, waits for it long
milliseconds to finish and returns T
,
otherwise times out with TimeoutException
.T
- the callable typemillis
- the millisecondscallable
- the callable