Class Executor
- java.lang.Object
-
- page.codeberg.terratactician_expandoria.Executor
-
public class Executor extends java.lang.Object
static helper class, for timed function execution.
-
-
Constructor Summary
Constructors Constructor Description Executor()
DO NOT USE: this is a static class (but gradle wants this comment)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
timed(java.util.concurrent.Callable<java.lang.Void> task, long ms)
Executes a Callable with a time limit.static <T> void
timedExecutorDetached(java.util.concurrent.Callable<T> task, int ms)
Executes a Callable with a time limit, but detached from the main thread.
-
-
-
Method Detail
-
timed
public static long timed(java.util.concurrent.Callable<java.lang.Void> task, long ms)
Executes a Callable with a time limit. Returns the result of the Callable.- Parameters:
task
- task to executems
- time till timeout in ms must be positive- Returns:
- time it actually took to execute the task will be negative in case of a timeout
-
timedExecutorDetached
public static <T> void timedExecutorDetached(java.util.concurrent.Callable<T> task, int ms)
Executes a Callable with a time limit, but detached from the main thread.- Type Parameters:
T
- return type of callable- Parameters:
task
- task to executems
- time limit in ms.
-
-