Class ExecutableTaskBase<R,S>
java.lang.Object
de.linusdev.lutils.async.executable.ExecutableTaskBase<R,S>
- Type Parameters:
R-S-
- All Implemented Interfaces:
ExecutableTask<R,,S> HasAsyncManager,PTask<R,,S> Task<R,S>
- Direct Known Subclasses:
QueueableBase
public abstract class ExecutableTaskBase<R,S>
extends Object
implements ExecutableTask<R,S>, PTask<R,S>
A executable
Example:
Task.
Example:
ExecutableTask<String, Nothing> task = new ExecutableTaskBase<>(manager) {
@Override
protected void launch(@NotNull ExecutableFuture<...> future) {
new Thread(() -> {
try {
future.executeHere();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}).start();
}
@Override
public @NotNull ComputationResult<String, Nothing> execute() throws InterruptedException {
Thread.sleep(5000);
return new ComputationResult<>("Woooow", Nothing.INSTANCE, null);
}
};
task.queue((result, secondary) -> System.out.println(result));-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconsumeAndQueue(@Nullable Consumer<Future<R, S>> consumer) @NotNull AsyncManagerprotected abstract voidlaunch(@NotNull ExecutableFuture<R, S, ExecutableTaskBase<R, S>> future) Launch the future created by thisTask.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.linusdev.lutils.async.executable.ExecutableTask
execute, executeHereMethods inherited from interface de.linusdev.lutils.async.PTask
queue, queue, queue, queue, queueAndSetBeforeExecutionListener, queueAndWait, queueAndWriteToFile
-
Constructor Details
-
ExecutableTaskBase
-
-
Method Details
-
consumeAndQueue
-
launch
protected abstract void launch(@NotNull @NotNull ExecutableFuture<R, S, ExecutableTaskBase<R, S>> future) Launch the future created by thisTask.
This means,ExecutableFuture.executeHere()should be called in a differentThread.- Parameters:
future- theExecutableFuturewhich should be launched/executed.
-
getAsyncManager
- Specified by:
getAsyncManagerin interfaceHasAsyncManager
-