Package com.rapidminer.belt.execution
Class SequentialContext
- java.lang.Object
-
- com.rapidminer.belt.execution.SequentialContext
-
-
Constructor Summary
Constructors Constructor Description SequentialContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> java.util.List<T>
call(java.util.List<java.util.concurrent.Callable<T>> callables)
Executes the givenCallable
s in parallel, returning their results upon completion.int
getParallelism()
Returns the targeted parallelism level of this execution context.boolean
isActive()
Returnstrue
if the execution context is active.void
stop()
Stops the execution for this context.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.rapidminer.belt.execution.Context
requireActive
-
-
-
-
Method Detail
-
isActive
public boolean isActive()
Description copied from interface:Context
Returnstrue
if the execution context is active. Inactive contexts may reject new jobs.
-
getParallelism
public int getParallelism()
Description copied from interface:Context
Returns the targeted parallelism level of this execution context.- Specified by:
getParallelism
in interfaceContext
- Returns:
- the targeted parallelism level
-
call
public <T> java.util.List<T> call(java.util.List<java.util.concurrent.Callable<T>> callables) throws java.util.concurrent.ExecutionException
Description copied from interface:Context
Executes the givenCallable
s in parallel, returning their results upon completion.If one of the
Callable
s encounters an exception, the context attempts to cancel the otherCallable
s and throws anExecutionException
that wraps the exception. If more than oneCallable
encounters an exception, only the first observed exception is reported.The method blocks until all
Callables
have completed.Note that the cancellation of one of the
Callable
s might not interrupt the execution of otherCallable
s that have already been started. As a consequence, it is recommended that all long-runningCallable
s periodically check for the cancellation of the computation viaContext.requireActive()
.- Specified by:
call
in interfaceContext
- Type Parameters:
T
- the type of the values returned from the callables- Parameters:
callables
- theCallable
s to execute in parallel- Returns:
- a list containing the results of the callables
- Throws:
java.util.concurrent.ExecutionException
- if the computation threw an exception
-
stop
public void stop()
Stops the execution for this context.
-
-