Class DefaultTickLoop.ScheduledTask<T>
java.lang.Object
java.util.concurrent.CompletableFuture<T>
eu.cloudnetservice.utils.base.concurrent.ListenableTask<T>
eu.cloudnetservice.node.impl.tick.DefaultTickLoop.ScheduledTask<T>
- All Implemented Interfaces:
CompletionStage<T>, Future<T>
- Enclosing class:
DefaultTickLoop
private static final class DefaultTickLoop.ScheduledTask<T>
extends eu.cloudnetservice.utils.base.concurrent.ListenableTask<T>
-
Nested Class Summary
Nested classes/interfaces inherited from class CompletableFuture
CompletableFuture.AsynchronousCompletionTaskNested classes/interfaces inherited from interface Future
Future.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longThe counter keeping track of the number of times this task was executedprivate final longThe number of times this task should execute.private longThe next tick this task is about to execute.private final longThe number of ticks between each call of this task.Fields inherited from class eu.cloudnetservice.utils.base.concurrent.ListenableTask
STATE_DONE, STATE_NEW, STATE_RUN -
Constructor Summary
ConstructorsConstructorDescriptionScheduledTask(@NonNull Callable<T> callable, long tickPeriod, long executionTimes, long nextScheduledTick) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanexecute(long currentTick) Executes this task and resets the future to prepare for the next execution.Methods inherited from class eu.cloudnetservice.utils.base.concurrent.ListenableTask
runMethods inherited from class CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, exceptionNow, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, resultNow, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, state, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
Field Details
-
tickPeriod
private final long tickPeriodThe number of ticks between each call of this task. -
executionTimes
private final long executionTimesThe number of times this task should execute. -
executionCounter
private long executionCounterThe counter keeping track of the number of times this task was executed -
nextScheduledTick
private long nextScheduledTickThe next tick this task is about to execute.
-
-
Constructor Details
-
ScheduledTask
-
-
Method Details
-
execute
private boolean execute(long currentTick) Executes this task and resets the future to prepare for the next execution.- Parameters:
currentTick- the current tick number.- Returns:
- true if this task terminated and should be unregistered after the execution, false otherwise.
-