public interface EvalContext
Task
evaluation and EvalContext.Value
computation.Modifier and Type | Interface and Description |
---|---|
static interface |
EvalContext.Promise<T>
A promise for a
EvalContext.Value that is supposed to be EvalContext.Promise.set(Object) . |
static interface |
EvalContext.Value<T>
A wrapped value with additional semantics for how the enclosed value becomes available and
how computations on that value are executed.
|
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Modifier and Type | Method and Description |
---|---|
static EvalContext |
async(Executor executor)
Create an asynchronous
EvalContext that executes all evaluation on the given
Executor . |
default Optional<Task<?>> |
currentTask()
When called during the evaluation of a task, this method will return the
Task
currently being processed. |
default <T> EvalContext.Value<T> |
evaluate(Task<T> task)
The entry point for evaluating a
EvalContext.Value from a Task . |
default <T> EvalContext.Value<T> |
evaluateInternal(Task<T> task,
EvalContext context)
A variant of
evaluate(Task) that allows the caller to specify the EvalContext
that should be used within the graph during evaluation. |
default <T> EvalContext.Value<T> |
immediateValue(T value)
Create a
EvalContext.Value with semantics defined by this EvalContext |
default <T> EvalContext.Value<T> |
invokeProcessFn(TaskId taskId,
Fn<T> processFn)
Invoke the process function of a task.
|
default TaskOperator.Listener |
listener()
Used to report task metadata.
|
<T> EvalContext.Promise<T> |
promise()
Create a promise for a value that can be fulfilled somewhere else.
|
static EvalContext |
sync()
Create a default, synchronous
EvalContext . |
<T> EvalContext.Value<T> |
value(Fn<T> value)
Create a
EvalContext.Value with semantics defined by this EvalContext |
default <T> EvalContext.Value<T> evaluate(Task<T> task)
EvalContext.Value
from a Task
.
All upstreams to the task will also be evaluated through this same method.
The implementation should define how and where evaluation happens.
This method is a good place to define how for instance value memoization happens.
T
- The type of the task resulttask
- The task to evaluatedefault <T> EvalContext.Value<T> evaluateInternal(Task<T> task, EvalContext context)
evaluate(Task)
that allows the caller to specify the EvalContext
that should be used within the graph during evaluation.
This is intended to be called from EvalContext
implementations that form a
composition of other contexts.
T
- The type of the task resulttask
- The task to evaluatecontext
- The context to use in further evaluationdefault <T> EvalContext.Value<T> invokeProcessFn(TaskId taskId, Fn<T> processFn)
This method will be called when the process function of a task is ready to be invoked. This
gives this EvalContext
the responsibility of invoking user code. By overriding this
method, one can intercept the evaluation flow just at the moment between inputs being ready
and when the user supplied function for task processing is being invoked.
The default implementation will simply invoke the function immediately inside a
EvalContext.Value
created by value(Fn)
.
T
- The task value typetaskId
- The id of the task being invokedprocessFn
- A lazily evaluated handle to the process functiondefault Optional<Task<?>> currentTask()
Task
currently being processed. Otherwise an empty value will be returned.
The return value of this method is stable for each instance of EvalContext
that is
passed into the process functions. Calls from multiple threads will see the same result as
longs as the calls are made to the same instance.
<T> EvalContext.Value<T> value(Fn<T> value)
EvalContext.Value
with semantics defined by this EvalContext
T
- The type of the valuevalue
- A value value supplierdefault <T> EvalContext.Value<T> immediateValue(T value)
EvalContext.Value
with semantics defined by this EvalContext
T
- The type of the valuevalue
- An actual value to wrap<T> EvalContext.Promise<T> promise()
T
- The type of the promised valuedefault TaskOperator.Listener listener()
static EvalContext sync()
EvalContext
. The values produced by this
context should behave like synchronously created values.static EvalContext async(Executor executor)
EvalContext
that executes all evaluation on the given
Executor
.executor
- The executor to run evaluations onCopyright © 2020. All rights reserved.