Class SingletonTask
- java.lang.Object
-
- org.hibernate.search.engine.backend.orchestration.spi.SingletonTask
-
public final class SingletonTask extends Object
A task that can be scheduled for a run and is guaranteed to never run concurrently, regardless of the thread pool it's submitted to.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SingletonTask.Scheduler
static interface
SingletonTask.Worker
-
Constructor Summary
Constructors Constructor Description SingletonTask(String name, SingletonTask.Worker worker, SingletonTask.Scheduler scheduler, FailureHandler failureHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<?>
completion()
void
ensureScheduled()
Ensures the task will run in the future.void
stop()
Stop the task.String
toString()
-
-
-
Constructor Detail
-
SingletonTask
public SingletonTask(String name, SingletonTask.Worker worker, SingletonTask.Scheduler scheduler, FailureHandler failureHandler)
-
-
Method Detail
-
ensureScheduled
public void ensureScheduled()
Ensures the task will run in the future.- If the task is neither scheduled nor running, this schedules the task for execution.
- If the task is already scheduled but not running, this does nothing: the task remains scheduled.
- If the task is running: the task execution continues and will trigger re-scheduling when it finishes.
-
completion
public CompletableFuture<?> completion()
- Returns:
- A future that completes when all works submitted to the executor so far are completely executed. Works submitted to the executor after entering this method may delay the wait.
-
stop
public void stop()
Stop the task.Callers must call this as the very last method on this object; any concurrent call may lead to unpredictable results.
-
-