public class InstrumentedContext extends ForwardingEvalContext
EvalContext
that instruments the task expansion and invocation process.
This context will invoke methods on a InstrumentedContext.Listener
when tasks are evaluated through the
EvalContext.evaluate(Task)
method.
The InstrumentedContext.Listener.task(Task)
method is called for each discovered task in the evaluating
task tree. The inputs of a task are all also announced to this method before a task starts
processing.
The Listener#status(TaskId, Listener.Phase)
method is called when a task is actually
being processed, i.e. when the invokeProcessFn(TaskId, Fn)
of that task in called in
the EvalContext
. There will be at most two calls made for
each task. First with InstrumentedContext.Listener.Phase.START
, when evaluation starts. Then with either
InstrumentedContext.Listener.Phase.SUCCESS
or InstrumentedContext.Listener.Phase.FAILURE
depending on the success or
failure of the task EvalContext.Value
.
Modifier and Type | Class and Description |
---|---|
static interface |
InstrumentedContext.Listener
A listener for instrumented evaluation.
|
EvalContext.Promise<T>, EvalContext.Value<T>
delegate
LOG
Modifier and Type | Method and Description |
---|---|
static EvalContext |
composeWith(EvalContext baseContext,
InstrumentedContext.Listener listener) |
<T> EvalContext.Value<T> |
evaluateInternal(Task<T> task,
EvalContext context)
A variant of
EvalContext.evaluate(Task) that allows the caller to specify the EvalContext
that should be used within the graph during evaluation. |
<T> EvalContext.Value<T> |
invokeProcessFn(TaskId taskId,
Fn<T> processFn)
Invoke the process function of a task.
|
TaskOperator.Listener |
listener()
Used to report task metadata.
|
immediateValue, promise, value
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
async, currentTask, evaluate, sync
public static EvalContext composeWith(EvalContext baseContext, InstrumentedContext.Listener listener)
public <T> EvalContext.Value<T> evaluateInternal(Task<T> task, EvalContext context)
EvalContext
EvalContext.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.
evaluateInternal
in interface EvalContext
evaluateInternal
in class ForwardingEvalContext
T
- The type of the task resulttask
- The task to evaluatecontext
- The context to use in further evaluationpublic <T> EvalContext.Value<T> invokeProcessFn(TaskId taskId, Fn<T> processFn)
EvalContext
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 EvalContext.value(Fn)
.
invokeProcessFn
in interface EvalContext
invokeProcessFn
in class ForwardingEvalContext
T
- The task value typetaskId
- The id of the task being invokedprocessFn
- A lazily evaluated handle to the process functionpublic TaskOperator.Listener listener()
EvalContext
listener
in interface EvalContext
listener
in class ForwardingEvalContext
Copyright © 2020. All rights reserved.