public class WorkThreadTrackingTask<T> extends ForkJoinTask<T>
ForkJoinTask
which keeps track of the thread running its
computation.
This task performs compute()
in a thread safe manner, guaranteeing only one
computation will happen even when called between multiple threads.
Modifier and Type | Field and Description |
---|---|
protected Thread |
workThread |
Constructor and Description |
---|
WorkThreadTrackingTask(java.util.function.Supplier<T> work) |
Modifier and Type | Method and Description |
---|---|
void |
complete(T value) |
static <T> WorkThreadTrackingTask<T> |
completed(T value) |
protected T |
compute() |
protected boolean |
exec() |
T |
externalCompute()
computes and completes this task, which can be called outside of the forkjoin framework, or by
threads that did not originally fork the task.
|
T |
getRawResult() |
boolean |
isBeingWorkedOnByCurrentThread() |
protected void |
setRawResult(T value) |
adapt, adapt, adapt, cancel, compareAndSetForkJoinTaskTag, completeExceptionally, fork, get, get, getException, getForkJoinTaskTag, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollTask, quietlyComplete, quietlyInvoke, quietlyJoin, reinitialize, setForkJoinTaskTag, tryUnfork
public WorkThreadTrackingTask(java.util.function.Supplier<T> work)
@Nullable public final T externalCompute()
Exceptions are propagated via UncheckedExecutionExceptions
public final boolean isBeingWorkedOnByCurrentThread()
public void complete(T value)
complete
in class ForkJoinTask<T>
@Nullable public T getRawResult()
getRawResult
in class ForkJoinTask<T>
protected void setRawResult(T value)
setRawResult
in class ForkJoinTask<T>
protected boolean exec()
exec
in class ForkJoinTask<T>
public static <T> WorkThreadTrackingTask<T> completed(T value)