TaskExecutor that runs every task on the current thread, i.e. in a sequential order. This
class is not designed to be used in production but should make code involving asynchronous operations deterministic
and testable.
| Modifier and Type | Class and Description |
|---|---|
| private static record |
| Modifier and Type | Field and Description |
|---|---|
| private static final Logger | |
| private final WeakHashMap |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public DelayTaskThrottler | createThrottler(int delay)
Implements org. Creates a new task throttler, and registers it so that it gets properly shutdown. |
| public <V> Future | execute(BackgroundTask<V> task)
Implements org. Executes the task on the current thread. |
| public <V> Future | schedule(BackgroundTask<V> task, long delay, TimeUnit unit)
Implements org. Submits a one-shot task that becomes enabled after the given delay. |
| public void |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| throttlers | back to summary |
|---|---|
| private final WeakHashMap<DelayTaskThrottler, Void> throttlers | |
| CurrentThreadTaskExecutor | back to summary |
|---|---|
| public CurrentThreadTaskExecutor() | |
| createThrottler | back to summary |
|---|---|
| public DelayTaskThrottler createThrottler(int delay) Implements org. Doc from org. Creates a new task throttler, and registers it so that it gets properly shutdown.
| |
| execute | back to summary |
|---|---|
| public <V> Future Implements org. Executes the task on the current thread. The code is essentially taken from
| |
| schedule | back to summary |
|---|---|
| public <V> Future Implements org. Doc from org. Submits a one-shot task that becomes enabled after the given delay.
| |
| shutdown | back to summary |
|---|---|
| public void shutdown() Implements org. Doc from org. Shutdown the task executor. May happen in the background or may be finished when this method returns.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Throwable | exception
Record Component accessed by exception(). |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | cancel(boolean mayInterruptIfRunning)
Implements java. Attempts to cancel execution of this task. |
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public Throwable | |
| public T | get()
Implements java. Waits if necessary for the computation to complete, and then retrieves its result. |
| public T | get(long timeout, TimeUnit unit)
Implements java. Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available. |
| public final int | |
| public boolean | isCancelled()
Implements java. Returns |
| public boolean | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| exception | back to summary |
|---|---|
| private final Throwable exception Record Component accessed by exception(). | |
| FailedFuture | back to summary |
|---|---|
| private FailedFuture(Throwable exception) | |
| cancel | back to summary |
|---|---|
| public boolean cancel(boolean mayInterruptIfRunning) Implements java. Doc from java. Attempts to cancel execution of this task. This method has no
effect if the task is already completed or cancelled, or could
not be cancelled for some other reason. Otherwise, if this
task has not started when The return value from this method does not necessarily
indicate whether the task is now cancelled; use
| |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| exception | back to summary |
|---|---|
| public Throwable exception() Record Component getter of exception. | |
| get | back to summary |
|---|---|
| public T get() throws ExecutionException Implements java. Doc from java. Waits if necessary for the computation to complete, and then retrieves its result.
| |
| get | back to summary |
|---|---|
| public T get(long timeout, TimeUnit unit) throws ExecutionException Implements java. Doc from java. Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| isCancelled | back to summary |
|---|---|
| public boolean isCancelled() Implements java. Doc from java. Returns
| |
| isDone | back to summary |
|---|---|
| public boolean isDone() Implements java. Doc from java. Returns
| |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |