| Modifier and Type | Class and Description |
|---|---|
| pack-priv static record | StructuredTaskScopeImpl.
Configuration implementation. |
| pack-priv static class | StructuredTaskScopeImpl.
Subtask implementation, runs the task specified to the fork method. |
| Modifier and Type | Field and Description |
|---|---|
| private static final VarHandle | |
| private volatile boolean | |
| private final ThreadFlock | |
| private final StructuredTaskScope. | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private volatile int | |
| private final ThreadFactory | |
| private volatile boolean | |
| private Future |
| Access | Constructor and Description |
|---|---|
| private | StructuredTaskScopeImpl(StructuredTaskScope.
|
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| public void | |
| private void | |
| public <U extends T> StructuredTaskScope. | fork(Callable<? extends U> task)
Implements java. Forks a subtask by starting a new thread in this scope to execute a value-returning method. |
| public <U extends T> StructuredTaskScope. | fork(Runnable task)
Implements java. Forks a subtask by starting a new thread in this scope to execute a method that does not return a result. |
| private void | |
| public boolean | isCancelled()
Implements java. Returns |
| private boolean | |
| public R | join()
Implements java. Returns a result, or throws, after waiting for all subtasks to complete or the scope to be cancelled. |
| private <U extends T> void | onComplete(StructuredTaskScopeImpl.
Invoked by the thread for a subtask when the subtask completes before scope is cancelled. |
| pack-priv static <T, R, R_X extends Throwable> StructuredTaskScope | open(StructuredTaskScope.
Hides java. Returns a new |
| private void | |
| public String |
| CANCELLED | back to summary |
|---|---|
| private static final VarHandle CANCELLED | |
| cancelled | back to summary |
|---|---|
| private volatile boolean cancelled | |
| flock | back to summary |
|---|---|
| private final ThreadFlock flock | |
| joiner | back to summary |
|---|---|
| private final StructuredTaskScope. | |
| ST_CLOSED | back to summary |
|---|---|
| private static final int ST_CLOSED | |
| ST_FORKED | back to summary |
|---|---|
| private static final int ST_FORKED | |
| ST_JOIN_COMPLETED | back to summary |
|---|---|
| private static final int ST_JOIN_COMPLETED | |
| ST_JOIN_STARTED | back to summary |
|---|---|
| private static final int ST_JOIN_STARTED | |
| state | back to summary |
|---|---|
| private volatile int state | |
| threadFactory | back to summary |
|---|---|
| private final ThreadFactory threadFactory | |
| timeoutExpired | back to summary |
|---|---|
| private volatile boolean timeoutExpired | |
| timerTask | back to summary |
|---|---|
| private Future<?> timerTask | |
| StructuredTaskScopeImpl | back to summary |
|---|---|
private StructuredTaskScopeImpl(StructuredTaskScope.
| |
| cancel | back to summary |
|---|---|
| private void cancel() Cancel the scope if not already cancelled. | |
| cancelTimeout | back to summary |
|---|---|
| private void cancelTimeout() Cancels the timer task if set. | |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this scope. This method first cancels the scope, if not already cancelled. This interrupts the threads executing unfinished subtasks. This method then waits for all threads to finish. If interrupted while waiting then it will continue to wait until the threads finish, before completing with the interrupted status set. This method may only be invoked by the scope owner. If the scope is already closed then the scope owner invoking this method has no effect. A
| |
| ensureOwner | back to summary |
|---|---|
| private void ensureOwner() Throws WrongThreadException if the current thread is not the owner thread. | |
| fork | back to summary |
|---|---|
| public <U extends T> StructuredTaskScope. Implements java. Doc from java. Forks a subtask by starting a new thread in this scope to execute a value-returning
method. The new thread executes the subtask concurrently with the current thread.
The parameter to this method is a If the scope was opened with a function to produce the This method returns a To ensure correct usage, the This method may only be invoked by the scope owner. Joiner Implementers: If the scope was opened with a If the subtask executes and completes (successfully or with an exception) before
the scope is cancelled, then the thread invokes the Joiner's
| |
| fork | back to summary |
|---|---|
| public <U extends T> StructuredTaskScope. Implements java. Doc from java. Forks a subtask by starting a new thread in this scope to execute a method that does not return a result. This method works exactly the same as
| |
| interruptAll | back to summary |
|---|---|
| private void interruptAll() Interrupts all threads in this scope, except the current thread. | |
| isCancelled | back to summary |
|---|---|
| public boolean isCancelled() Implements java. Doc from java. Returns Cancelling the scope prevents new threads from starting in the scope and
interrupts threads executing unfinished subtasks.
It may take some time before the interrupted threads finish execution; this
method may return
| |
| isJoinCompleted | back to summary |
|---|---|
| private boolean isJoinCompleted() Returns true if join has been invoked and there is an outcome. | |
| join | back to summary |
|---|---|
| public R join() throws Joiner:R_X, InterruptedException Implements java. Doc from java. Returns a result, or throws, after waiting for all subtasks to complete or the scope to be cancelled. If the scope was opened with the If the scope was opened with a This method may only be invoked by the scope owner. It may only be invoked once
to get the result, exception or timeout outcome, unless the previous invocation
resulted in an Joiner Implementers: When all subtasks complete, or the scope cancelled, this method invokes the
| |
| onComplete | back to summary |
|---|---|
| private <U extends T> void onComplete(StructuredTaskScopeImpl. Invoked by the thread for a subtask when the subtask completes before scope is cancelled. | |
| open | back to summary |
|---|---|
| pack-priv static <T, R, R_X extends Throwable> StructuredTaskScope Hides java. Returns a new | |
| scheduleTimeout | back to summary |
|---|---|
| private void scheduleTimeout(Duration timeout) Schedules a task to cancel the scope on timeout. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final ThreadFactory | threadFactory
Record Component accessed by threadFactory(). |
| private final Duration |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static StructuredTaskScope. | |
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public String | |
| public ThreadFactory | |
| public Duration | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| public StructuredTaskScope. | withName(String name)
Implements java. Returns a new |
| public StructuredTaskScope. | withThreadFactory(ThreadFactory threadFactory)
Implements java. Returns a new |
| public StructuredTaskScope. | withTimeout(Duration timeout)
Implements java. Returns a new |
| name | back to summary |
|---|---|
| private final String name Record Component accessed by name(). | |
| threadFactory | back to summary |
|---|---|
| private final ThreadFactory threadFactory Record Component accessed by threadFactory(). | |
| timeout | back to summary |
|---|---|
| private final Duration timeout Record Component accessed by timeout(). | |
| ConfigImpl | back to summary |
|---|---|
| pack-priv ConfigImpl(ThreadFactory threadFactory, String name, Duration timeout) | |
| defaultConfig | back to summary |
|---|---|
| pack-priv static StructuredTaskScope. | |
| 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).
| |
| 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 | |
| name | back to summary |
|---|---|
| public String name() Record Component getter of name. | |
| threadFactory | back to summary |
|---|---|
| public ThreadFactory threadFactory() Record Component getter of threadFactory. | |
| timeout | back to summary |
|---|---|
| public Duration timeout() Record Component getter of timeout. | |
| 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. | |
| withName | back to summary |
|---|---|
| public StructuredTaskScope. Implements java. Doc from java. Returns a new
| |
| withThreadFactory | back to summary |
|---|---|
| public StructuredTaskScope. Implements java. Doc from java. Returns a new
| |
| withTimeout | back to summary |
|---|---|
| public StructuredTaskScope. Implements java. Doc from java. Returns a new
| |
| Modifier and Type | Class and Description |
|---|---|
| private static record |
| Modifier and Type | Field and Description |
|---|---|
| private volatile Object | |
| private static final StructuredTaskScopeImpl. | |
| private final StructuredTaskScopeImpl | |
| private final Callable | |
| private Thread |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private void | ensureJoinedIfNotSubtask()
Throws IllegalStateException if the caller thread is not the subtask and the scope owner has not joined. |
| public Throwable | exception()
Implements java. Returns the exception or error thrown by this subtask if it failed. |
| public T | get()
Implements java. Returns the result of this subtask if it completed successfully. |
| public void | |
| pack-priv void | |
| public StructuredTaskScope. | state()
Implements java. Returns the subtask state. |
| public String |
| result | back to summary |
|---|---|
| private volatile Object result | |
| RESULT_NULL | back to summary |
|---|---|
| private static final StructuredTaskScopeImpl. | |
| scope | back to summary |
|---|---|
| private final StructuredTaskScopeImpl<? super T, ?, ?> scope | |
| task | back to summary |
|---|---|
| private final Callable<? extends T> task | |
| thread | back to summary |
|---|---|
| private Thread thread
| |
| SubtaskImpl | back to summary |
|---|---|
| pack-priv SubtaskImpl(StructuredTaskScopeImpl<? super T, ?, ?> scope, Callable<? extends T> task) | |
| ensureJoinedIfNotSubtask | back to summary |
|---|---|
| private void ensureJoinedIfNotSubtask() Throws IllegalStateException if the caller thread is not the subtask and the scope owner has not joined. | |
| exception | back to summary |
|---|---|
| public Throwable exception() Implements java. Doc from java. Returns the exception or error thrown by this subtask if it failed.
If the scope is cancelled, the
subtask failed before the scope was cancelled. If the subtask was forked with
Code executing in the scope owner thread can use this method to get the exception thrown by a failed subtask after it has joined. Code executing in a This method may be invoked by any thread after the scope owner has joined.
The only case where this method can be used to get the exception before the scope
owner has joined is when called from the
| |
| get | back to summary |
|---|---|
| public T get() Implements java. Doc from java. Returns the result of this subtask if it completed successfully. If the scope
is cancelled, the subtask
completed successfully before the scope was cancelled. If the subtask was
forked with Code executing in the scope owner thread can use this method to get the result of a successful subtask after it has joined. Code executing in the This method may be invoked by any thread after the scope owner has joined.
The only case where this method can be used to get the result before the scope
owner has joined is when called from the
| |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| setThread | back to summary |
|---|---|
| pack-priv void setThread(Thread thread) Sets the thread for this subtask. | |
| state | back to summary |
|---|---|
| public StructuredTaskScope. Implements java. Doc from java. Returns the subtask state.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Throwable | exception
Record Component accessed by exception(). |
| private final StructuredTaskScope. |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public Throwable | |
| public final int | |
| public StructuredTaskScope. | |
| 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(). | |
| state | back to summary |
|---|---|
| private final StructuredTaskScope. Record Component accessed by state(). | |
| AltResult | back to summary |
|---|---|
| pack-priv AltResult(StructuredTaskScope. | |
| AltResult | back to summary |
|---|---|
| private AltResult(StructuredTaskScope. | |
| 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. | |
| 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 | |
| state | back to summary |
|---|---|
| public StructuredTaskScope. Record Component getter of state. | |
| 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. | |