Package ai.preferred.venom
Interface Worker
-
- All Known Implementing Classes:
ThreadedWorkerManager.AbstractManagedBlockingWorker
public interface Worker- Author:
- Maksim Tkachenko, Ween Jiann Lee
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidexecuteBlockingIO(@NotNull java.lang.Runnable task)Performs the given task inline, and increase available threads in the pool by one for the execution of other tasks.@NotNull java.util.concurrent.Future<?>submit(@NotNull java.lang.Runnable task)Submits a Runnable task for execution and returns a Future representing that task.<T> @NotNull java.util.concurrent.Future<T>submit(@NotNull java.lang.Runnable task, T result)Submits a Runnable task for execution and returns a Future representing that task.<T> @NotNull java.util.concurrent.Future<T>submit(@NotNull java.util.concurrent.Callable<T> task)Submits a value-returning task for execution and returns a Future representing the pending results of the task.
-
-
-
Method Detail
-
executeBlockingIO
void executeBlockingIO(@NotNull @NotNull java.lang.Runnable task)Performs the given task inline, and increase available threads in the pool by one for the execution of other tasks.It is imperative to wrap all I/O tasks in this method to prevent starving other parsing tasks from threads.
- Parameters:
task- the I/O blocking task to execute- Throws:
java.lang.NullPointerException- if the task is null
-
submit
@NotNull <T> @NotNull java.util.concurrent.Future<T> submit(@NotNull @NotNull java.util.concurrent.Callable<T> task)Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future'sgetmethod will return the task's result upon successful completion.
If you would like to immediately block waiting for a task, you can use constructions of the formresult = exec.submit(aCallable).get();Note: The
Executorsclass includes a set of methods that can convert some other common closure-like objects, for example,PrivilegedActiontoCallableform so they can be submitted.- Type Parameters:
T- the type of the task's result- Parameters:
task- the task to submit- Returns:
- a Future representing pending completion of the task
- Throws:
java.util.concurrent.RejectedExecutionException- if the task cannot be scheduled for executionjava.lang.NullPointerException- if the task is null
-
submit
@NotNull <T> @NotNull java.util.concurrent.Future<T> submit(@NotNull @NotNull java.lang.Runnable task, T result)Submits a Runnable task for execution and returns a Future representing that task. The Future'sgetmethod will return the given result upon successful completion.- Type Parameters:
T- the type of the result- Parameters:
task- the task to submitresult- the result to return- Returns:
- a Future representing pending completion of the task
- Throws:
java.util.concurrent.RejectedExecutionException- if the task cannot be scheduled for executionjava.lang.NullPointerException- if the task is null
-
submit
@NotNull @NotNull java.util.concurrent.Future<?> submit(@NotNull @NotNull java.lang.Runnable task)Submits a Runnable task for execution and returns a Future representing that task. The Future'sgetmethod will returnnullupon successful completion.- Parameters:
task- the task to submit- Returns:
- a Future representing pending completion of the task
- Throws:
java.util.concurrent.RejectedExecutionException- if the task cannot be scheduled for executionjava.lang.NullPointerException- if the task is null
-
-