R - type of return resultpublic static class SupplierTask.SupplierTask0<R> extends Object implements SupplierTask<R>
SupplierTask.SupplierTask0<R>, SupplierTask.SupplierTask1<T,R>, SupplierTask.SupplierTask2<T,U,R>| Constructor and Description |
|---|
SupplierTask0(Engine engine,
Supplier<R> fn) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<R> |
apply()
Creates a CompletableFuture around the lambda expression.
|
Object |
before(TaskRun taskRun)
Called before
TaskRunner.executeTaskMethod(TaskRun, Thread, Object), but in the parent thread. |
protected <RV> com.ebay.bascomtask.core.BascomTaskFuture<RV> |
ensureWrapped(CompletableFuture<RV> cf,
boolean registerAsDependentInput)
Ensures the provided CF is or is wrapped by a BT-controlled CF, and registered as an input argument.
|
Object |
executeTaskMethod(TaskRun taskRun,
Thread parentThread,
Object fromBefore)
Task invocation -- an implementation should invoke
TaskRun.run()
to complete the invocation (unless there is some reason to prevent it, but then the implementation
must take responsibility to ensure the all CompletableFuture return values are completed). |
void |
formatActualSignature(StringBuilder sb) |
long |
getCompletedAt()
Returns the time at which this task method was completed, which for CompletableFutures is the time
at which it had a value assigned.
|
long |
getEndedAt()
Returns the time at which this task method was ended.
|
String |
getName()
Returns the task name, e.g.
|
long |
getStartedAt()
Returns the time at which this task method was started.
|
TaskInterface<?> |
getTask()
Returns the user task pojo if there is one.
|
String |
getTaskPlusMethodName() |
protected Object |
invokeTaskMethod() |
boolean |
isLight() |
boolean |
isRunSpawned() |
THIS |
name(String name) |
void |
onComplete(TaskRun taskRun,
Object fromBefore,
boolean doneOnExit)
Called once any CompletableFuture return result completes, which may be before the call to
TaskRun.run() or after if a method returns an incomplete CompletableFuture.
|
Object |
run() |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitactivate, complete, complete, get, getName, isActivate, isLight, isRunSpawned, light, name, runSpawnedcompletedBefore, overlapped@Light public CompletableFuture<R> apply()
SupplierTaskapply in interface SupplierTask<R>public THIS name(String name)
public TaskInterface<?> getTask()
TaskRunpublic void formatActualSignature(StringBuilder sb)
protected Object invokeTaskMethod()
public boolean isLight()
public boolean isRunSpawned()
protected <RV> com.ebay.bascomtask.core.BascomTaskFuture<RV> ensureWrapped(CompletableFuture<RV> cf, boolean registerAsDependentInput)
RV - type of return valuecf - to ensureregisterAsDependentInput - if argument should be added to inputs listpublic Object before(TaskRun taskRun)
TaskRunnerTaskRunner.executeTaskMethod(TaskRun, Thread, Object), but in the parent thread.
If there is no immediate spawning then it will be the same thread. The returned object will
simply be passed to executeTaskMethod and is otherwise not read or modified by the framework.before in interface TaskRunnertaskRun - that will also be passed to executeTaskMethodpublic Object executeTaskMethod(TaskRun taskRun, Thread parentThread, Object fromBefore)
TaskRunnerTaskRun.run()
to complete the invocation (unless there is some reason to prevent it, but then the implementation
must take responsibility to ensure the all CompletableFuture return values are completed). A typical
subclass implementation would be to simply surround the call, e.g.:
public Object executeTaskMethod(TaskRun taskRun, Thread parentThread, Object fromBefore) {
LOG.info("STARTED " + taskRun.getTaskPlusMethodName());
try {
taskRun.run()
} finally {
LOG.info("ENDED " + taskRun.getTaskPlusMethodName());
}
}
executeTaskMethod in interface TaskRunnertaskRun - to executeparentThread - of spawned task, which may be same as Thread.currentThread()fromBefore - value returned from TaskRunner.before(TaskRun)public void onComplete(TaskRun taskRun, Object fromBefore, boolean doneOnExit)
TaskRunnerThe provided doneOnExit parameter indicates whether a CompletableFuture return value had isDone()==true when the method completed. This should not be taken as very close but not exactly precise, since there are very small time intervals involved in the steps behind making that determination.
onComplete in interface TaskRunnertaskRun - that was executedfromBefore - value returned from TaskRunner.before(TaskRun)doneOnExit - false iff a CompletableFuture was returned and it was not done when the method exitedpublic final String getName()
TaskRunpublic final String getTaskPlusMethodName()
getTaskPlusMethodName in interface TaskRunpublic long getStartedAt()
TaskMetagetStartedAt in interface TaskMetapublic long getEndedAt()
TaskMetaTaskMeta.getStartedAt().getEndedAt in interface TaskMetapublic long getCompletedAt()
TaskMetaTaskMeta.getEndedAt(),
and is greater than the ending time iff the CompletableFuture had !isDone() on method exit.getCompletedAt in interface TaskMetaCopyright © 2021. All rights reserved.