Package de.linusdev.lutils.async.queue
Class QueueableBase<T,R extends QResponse>
java.lang.Object
de.linusdev.lutils.async.executable.ExecutableTaskBase<T,R>
de.linusdev.lutils.async.queue.QueueableBase<T,R>
- Type Parameters:
T- return typeR- response type
- All Implemented Interfaces:
ExecutableTask<T,,R> HasAsyncManager,HasAsyncQueue<R>,PTask<T,,R> Queueable<T,,R> Task<T,R>
public abstract class QueueableBase<T,R extends QResponse>
extends ExecutableTaskBase<T,R>
implements Queueable<T,R>
Queueable base.
Example:
QueueableImpl<String, Nothing> queueable = new QueueableImpl<>(manager) {
@Override
@NotNull
public ComputationResult<String, Nothing> execute()
throws InterruptedException {
//Execute task
Thread.sleep(3000);
return new ComputationResult<>("test", Nothing.INSTANCE, null);
}
};
Queueable<String, Nothing> qableToReturn = queueable;
//End User:
String result = qableToReturn.queue().getResult();
System.out.println("Result: " + result);-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconsumeAndQueue(@Nullable Consumer<Future<T, R>> consumer) @NotNull AsyncQueue<R>protected voidlaunch(@NotNull ExecutableFuture<T, R, ExecutableTaskBase<T, R>> future) Launch the future created by thisTask.Methods inherited from class de.linusdev.lutils.async.executable.ExecutableTaskBase
getAsyncManagerMethods 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.manager.HasAsyncManager
getAsyncManagerMethods inherited from interface de.linusdev.lutils.async.PTask
queue, queue, queue, queue, queueAndSetBeforeExecutionListener, queueAndWait, queueAndWriteToFile
-
Field Details
-
asyncQueue
-
-
Constructor Details
-
QueueableBase
-
-
Method Details
-
consumeAndQueue
@NotNull public @NotNull Future<T,R> consumeAndQueue(@Nullable @Nullable Consumer<Future<T, R>> consumer) - Specified by:
consumeAndQueuein interfacePTask<T,R extends QResponse> - Overrides:
consumeAndQueuein classExecutableTaskBase<T,R extends QResponse> - Parameters:
consumer-Consumerto set listeners before the Future is queued.- Returns:
Future
-
launch
Description copied from class:ExecutableTaskBaseLaunch the future created by thisTask.
This means,ExecutableFuture.executeHere()should be called in a differentThread.- Specified by:
launchin classExecutableTaskBase<T,R extends QResponse> - Parameters:
future- theExecutableFuturewhich should be launched/executed.
-
getAsyncQueue
- Specified by:
getAsyncQueuein interfaceHasAsyncQueue<T>
-