Scopes.supervised(Scoped)
or Scopes.unsupervised(ScopedUnsupervised)
concurrency scope.
Represents a capability to fork supervised or unsupervised, asynchronously running computations in a concurrency
scope. Such forks can be created using fork(java.util.concurrent.Callable<T>)
, forkUser(java.util.concurrent.Callable<T>)
,
UnsupervisedScope.forkCancellable(java.util.concurrent.Callable<T>)
or UnsupervisedScope.forkUnsupervised(java.util.concurrent.Callable<T>)
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T> Fork
<T> Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosingScopes.supervised(Scoped)
block completes.<T> Fork
<T> Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosingScopes.supervised(Scoped)
block completes.Methods inherited from class com.softwaremill.jox.structured.UnsupervisedScope
forkCancellable, forkUnsupervised
-
Method Details
-
fork
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosingScopes.supervised(Scoped)
block completes.The fork behaves as a daemon thread. That is, if the body of the scope completes successfully, and all other user forks (created using
forkUser(Callable)
) complete successfully, the scope will end, cancelling all running forks (including this one, if it's still running). That is, successful completion of this fork isn't required to end the scope.An exception thrown while evaluating
f
will cause the fork to fail and the enclosing scope to end (cancelling all other running forks).For alternate behaviors regarding ending the scope, see
forkUser(java.util.concurrent.Callable<T>)
,UnsupervisedScope.forkCancellable(java.util.concurrent.Callable<T>)
andUnsupervisedScope.forkUnsupervised(java.util.concurrent.Callable<T>)
. -
forkUser
Starts a fork (logical thread of execution), which is guaranteed to complete before the enclosingScopes.supervised(Scoped)
block completes.The fork behaves as a user-level thread. That is, the scope won't end until the body of the scope, and all other user forks (including this one) complete successfully. That is, successful completion of this fork is required to end the scope.
An exception thrown while evaluating
f
will cause the enclosing scope to end (cancelling all other running forks).For alternate behaviors regarding ending the scope, see
fork(java.util.concurrent.Callable<T>)
,UnsupervisedScope.forkCancellable(java.util.concurrent.Callable<T>)
andUnsupervisedScope.forkUnsupervised(java.util.concurrent.Callable<T>)
.
-