Interface InvocationControl
public interface InvocationControl
Host-owned controls for one managed invocation, safe to consult across its asynchronous work.
Implementations are thread-safe and retain the same logical deadline, cancellation state and
physical-work tracker. A cancellation request or expired caller reply never proves that an
application effect was undone or that its worker exited. This handle grants no new principal,
resource permission or durable deduplication guarantee.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReports a cooperative cancellation request without promising interruption or rollback.Returns a bounded executor that attaches this invocation's safe contexts for each task.Returns the nonnegative remaining budget of this invocation's original monotonic deadline.<T> CompletionStage<T> Submits bounded host-tracked child work with this invocation's context and ownership.static InvocationControlReturns the immutable control used outside managed invocation dispatch.
-
Method Details
-
remainingBudget
Duration remainingBudget()Returns the nonnegative remaining budget of this invocation's original monotonic deadline. A child operation may shorten this budget and must never restart or extend it.- Returns:
- remaining duration, or zero when expired or outside an invocation
-
cancellationRequested
boolean cancellationRequested()Reports a cooperative cancellation request without promising interruption or rollback. Application work must check this flag or use its own cooperative termination mechanism.- Returns:
- true when cancellation of the current invocation was requested
-
submit
Submits bounded host-tracked child work with this invocation's context and ownership. The host retains physical ownership until the callable actually exits, including its context cleanup. Cancelling the returned stage does not establish worker exit and does not release admission permits or call-scoped resources early. Submission after physical release is rejected.- Type Parameters:
T- result type- Parameters:
work- child work; must not be null- Returns:
- child result stage; cancellation is cooperative and does not imply effect reversal
- Throws:
NullPointerException- if work is nullIllegalStateException- when no invocation is active or its ownership has endedRejectedExecutionException- when the host's finite capacity is full
-
contextualExecutor
Executor contextualExecutor()Returns a bounded executor that attaches this invocation's safe contexts for each task. Arbitrary application executors do not inherit managed context automatically. Host-tracked execution retains physical ownership until task exit; the returned executor is borrowed and must not close the host executor. Execution after physical release is rejected.- Returns:
- invocation-owned contextual executor
- Throws:
IllegalStateException- when no invocation is active or its ownership has ended
-