/**
* The command to be executed. Must be passed as a runnable to the constructor
* or if parameters are necessary, it must be a {@link Function} that takes a
- * {@link GenericCommandOption} as the single parameter and always returns null
+ * {@link CommandOption} as the single parameter and always returns null
*/
final Function<CommandOption, Void> command;
CommandOption arguments = new CommandOption();
/**
+ * Create a command from a function with no return value
*
- * @param command
- * @param arguments
+ * @param command The result-less function
+ * @param arguments The arguments for the function as a {@link CommandOption}
*/
public Command(Function<CommandOption, Void> command, CommandOption arguments) {
this.command = command;
}
/**
+ * Create a command from a function with no return value
*
- * @param command A {@link Function} that takes a {@link GenericCommandOption}
+ * @param command A {@link Function} that takes a {@link CommandOption}
*/
public Command(Function<CommandOption, Void> command) {
this.command = command;
* Execute the command with the previously provided arguments
*
* @apiNote This method has a shorthand property where you can provide
- * {@link GenericCommandOption command options}
- * @see #exec(GenericCommandOption)
- * @see #bindArguments(GenericCommandOption)
+ * {@link CommandOption command options}
+ * @see #exec(CommandOption)
+ * @see #bindArguments(CommandOption)
*/
public void exec() {
this.command.apply(arguments);
/**
* Binds arguments to the command
*
- * @param args A {@link GenericCommandOption} object holding the command
+ * @param args A {@link CommandOption} object holding the command
* arguments and
* their values
* @return the {@link Command} object itself
};
/**
- * Executes a command with a {@link GenericCommandOption}
+ * Executes a command with a {@link CommandOption}
*
- * @param arguments A {@link GenericCommandOption} object holding necessary
+ * @param arguments A {@link CommandOption} object holding necessary
* parameters
* @throws InvalidArgumentsError
*/
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
+/**
+ * Parallel batch processing utilities
+ *
+ * @since 1.4.0
+ *
+ * @author Robin Cheney
+ */
public class ParallelProcessor {
+ /**
+ * Runs the given function ONCE in every thread using the given number of
+ * threads.
+ *
+ * @param function The {@link Runnable} to execute for this task.
+ * @param threads Max. number of threads to use
+ */
public static void run(Runnable function, int threads) {
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads);
for (int i = 0; i < threads; i++) {
/**
* Runs the given task repeatedly using the given number of threads until
* the provided condition becomes true.
+ *
+ * @param task The {@link Runnable} to execute for this task.
+ * @param threads Max. number of threads to use
+ * @param stopCondition stopping condition. pass a lambda function or a function
+ * reference to return a boolean value. {@code true} will
+ * stop execution, {@code false} will continue
*/
public static void runUntil(Runnable task, int threads, Supplier<Boolean> stopCondition) {
ExecutorService executor = Executors.newFixedThreadPool(threads);