Class UnsupervisedScope
- Direct Known Subclasses:
Scope
Scopes.unsupervised(ScopedUnsupervised)
concurrency scope (as well as, via
subtyping, by Scopes.supervised(Scoped)
).
Represents a capability to fork unsupervised, asynchronously running computations in a concurrency scope. Such forks
can be created using forkUnsupervised(java.util.concurrent.Callable<T>)
or forkCancellable(java.util.concurrent.Callable<T>)
.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> CancellableFork
<T> forkCancellable
(Callable<T> f) Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosingScopes.supervised(Scoped)
, orScopes.unsupervised(ScopedUnsupervised)
block completes, and which can be cancelled on-demand.<T> Fork
<T> forkUnsupervised
(Callable<T> f) Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosingScopes.supervised(Scoped)
, orScopes.unsupervised(ScopedUnsupervised)
block completes.
-
Constructor Details
-
UnsupervisedScope
public UnsupervisedScope()
-
-
Method Details
-
forkUnsupervised
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosingScopes.supervised(Scoped)
, orScopes.unsupervised(ScopedUnsupervised)
block completes.In case an exception is thrown while evaluating
f
, it will be thrown when calling the returnedFork
's.join()
method.Success or failure isn't signalled to the enclosing scope, and doesn't influence the scope's lifecycle.
For alternate behaviors, see
Scope.fork(java.util.concurrent.Callable<T>)
,Scope.forkUser(java.util.concurrent.Callable<T>)
,forkCancellable(java.util.concurrent.Callable<T>)
. -
forkCancellable
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosingScopes.supervised(Scoped)
, orScopes.unsupervised(ScopedUnsupervised)
block completes, and which can be cancelled on-demand.In case an exception is thrown while evaluating
f
, it will be thrown when calling the returnedCancellableFork
's.join()
method.The fork is unsupervised (similarly to
forkUnsupervised(Callable)
), hence success or failure isn't signalled to the enclosing scope and doesn't influence the scope's lifecycle.For alternate behaviors, see
Scope.fork(java.util.concurrent.Callable<T>)
,Scope.forkUser(java.util.concurrent.Callable<T>)
andforkUnsupervised(java.util.concurrent.Callable<T>)
.Implementation note: a cancellable fork is created by starting a nested scope in a fork, and then starting a fork there. Hence, it is more expensive than
Scope.fork(java.util.concurrent.Callable<T>)
, as two virtual threads are started.
-