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 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));