public final class DefaultAsyncScope
extends Object
implements AsyncScope
Default implementation of AsyncScope providing structured concurrency with configurable failure policy.
A dedicated lock guards the child task list and the closed flag jointly, ensuring that async(Supplier) and close() cannot race. Child futures are registered under the lock before task submission (register-before-submit protocol), guaranteeing every child is joined or cancelled by close().
| Constructor and description |
|---|
DefaultAsyncScope(Executor executor, boolean failFast) |
DefaultAsyncScope(Executor executor) |
DefaultAsyncScope() |
| Type Params | Return Type | Name and description |
|---|---|---|
<T> |
public Awaitable<T> |
async(Supplier<T> supplier) |
|
public void |
cancelAll() |
|
public void |
close() |
|
public static AsyncScope |
current()Returns the current scope, or null when no scope is bound. |
|
public int |
getChildCount() |
|
public AsyncScope |
getParent() |
|
public String |
toString() |
<T> |
public static T |
withCurrent(AsyncScope scope, Supplier<T> supplier)Executes the supplier with the given scope as current, restoring the previous binding afterwards. |
<T> |
public static T |
withScopeTimeout(Executor executor, Duration timeout, Function<AsyncScope, T> body)Creates a scope with a timeout. |
Returns the current scope, or null when no scope is bound.
Executes the supplier with the given scope as current, restoring the previous binding afterwards.
Creates a scope with a timeout. If the body does not complete within the duration, all children are cancelled and TimeoutException is thrown.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.