W3cubDocs

/OpenJDK 21

Interface StructuredTaskScope.Subtask<T>

Type Parameters:
T - the result type
All Superinterfaces:
Supplier<T>
Enclosing class:
StructuredTaskScopePREVIEW<T>
public static sealed interface StructuredTaskScope.Subtask<T> extends Supplier<T>
Subtask is a preview API of the Java platform.
Programs can only use Subtask when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Represents a subtask forked with StructuredTaskScope.fork(Callable)PREVIEW.
Since:
21

Nested Class Summary

Modifier and Type Interface Description
static enum  StructuredTaskScope.Subtask.StatePREVIEW
Preview.
Represents the state of a subtask.

Method Summary

Modifier and Type Method Description
Throwable exception()
Returns the exception thrown by the subtask.
T get()
Returns the result of the subtask.
StructuredTaskScope.Subtask.StatePREVIEW state()
Returns the state of the subtask.
Callable<? extends T> task()
Returns the value returning task provided to the fork method.

Method Details

task

Callable<? extends T> task()
Returns the value returning task provided to the fork method.
API Note:
Task objects with unique identity may be used for correlation by implementations of handleCompletePREVIEW.
Returns:
the value returning task provided to the fork method

state

StructuredTaskScope.Subtask.StatePREVIEW state()
Returns the state of the subtask.
Returns:
the state of the subtask

get

T get()
Returns the result of the subtask.

To ensure correct usage, if the scope owner forksPREVIEW a subtask, then it must join (with joinPREVIEW or joinUntilPREVIEW) before it can obtain the result of the subtask.

Specified by:
get in interface Supplier<T>
Returns:
the possibly-null result
Throws:
IllegalStateException - if the subtask has not completed, did not complete successfully, or the current thread is the task scope owner and did not join after forking
See Also:

exception

Throwable exception()
Returns the exception thrown by the subtask.

To ensure correct usage, if the scope owner forksPREVIEW a subtask, then it must join (with joinPREVIEW or joinUntilPREVIEW) before it can obtain the exception thrown by the subtask.

Returns:
the exception thrown by the subtask
Throws:
IllegalStateException - if the subtask has not completed, completed with a result, or the current thread is the task scope owner and did not join after forking
See Also:

© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/concurrent/StructuredTaskScope.Subtask.html