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 <T> T
timedExecutor(java.util.concurrent.Callable<T> task, int 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
-
timedExecutor
public static <T> T timedExecutor(java.util.concurrent.Callable<T> task, int ms) throws java.lang.Exception
Executes a Callable with a time limit. Returns the result of the Callable.- Type Parameters:
T
- return type- Parameters:
task
- task to executems
- time limit in ms.- Returns:
- T
- Throws:
java.lang.Exception
- gets thrown when execution fails in caller method.
-
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.
-
-