public abstract class TreeFuture<T extends PotentiallyPartialResult>
extends java.lang.Object
FutureTask
to allow calculating the same result across threads.Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.RunnableFuture<T> |
mFutureTask |
protected boolean |
mMoveOperationsBetweenThreads |
protected java.util.concurrent.atomic.AtomicInteger |
mRunningThreadId |
Constructor and Description |
---|
TreeFuture(boolean moveOperationsBetweenThreads) |
Modifier and Type | Method and Description |
---|---|
protected Systracer.ArgsBuilder |
addSystraceArgs(Systracer.ArgsBuilder argsBuilder)
Override to add additional args to a systrace.
|
protected abstract T |
calculate()
Calculates a new result for this TreeFuture.
|
int |
getWaitingCount() |
abstract boolean |
isEquivalentTo(TreeFuture that)
Returns true if the provided TreeFuture is equivalent to this one.
|
protected void |
onGetEnd(boolean isTracing)
Called after Get is completed.
|
protected void |
onGetStart(boolean isTracing)
Called before the future's Get is invoked.
|
protected void |
onWaitEnd(boolean isTracing,
boolean errorOccurred)
Called after Wait ends.
|
protected void |
onWaitStart(boolean isTracing)
Called before Wait starts.
|
protected abstract T |
resumeCalculation(T partialResult)
Resumes an interrupted calculation based on a partial result
|
protected final java.util.concurrent.atomic.AtomicInteger mRunningThreadId
protected final java.util.concurrent.RunnableFuture<T extends PotentiallyPartialResult> mFutureTask
protected final boolean mMoveOperationsBetweenThreads
protected abstract T calculate()
protected abstract T resumeCalculation(T partialResult)
public abstract boolean isEquivalentTo(TreeFuture that)
public int getWaitingCount()
protected void onGetStart(boolean isTracing)
protected void onGetEnd(boolean isTracing)
protected void onWaitStart(boolean isTracing)
protected void onWaitEnd(boolean isTracing, boolean errorOccurred)
protected Systracer.ArgsBuilder addSystraceArgs(Systracer.ArgsBuilder argsBuilder)