Package cc.redberry.rings.util
Class TimeConstrained
- java.lang.Object
-
- cc.redberry.rings.util.TimeConstrained
-
public class TimeConstrained extends Object
-
-
Constructor Summary
Constructors Constructor Description TimeConstrained()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TtimeConstrained(Callable<T> lambda, long millis)Runs lambda, stopping after specified number of millisecondsstatic <T> TtimeConstrained(Callable<T> lambda, long millis, T failExpr)Runs lambda, stopping after specified number of millisecondsstatic <T> TtimeConstrained0(Callable<T> lambda, long millis, T failExpr)Runs lambda, stopping after specified number of milliseconds
-
-
-
Method Detail
-
timeConstrained0
public static <T> T timeConstrained0(Callable<T> lambda, long millis, T failExpr) throws InterruptedException, ExecutionException
Runs lambda, stopping after specified number of milliseconds- Parameters:
lambda- code blockmillis- time constrained in millisecondsfailExpr- returns this if the time constraint is not met- Throws:
InterruptedExceptionExecutionException
-
timeConstrained
public static <T> T timeConstrained(Callable<T> lambda, long millis, T failExpr)
Runs lambda, stopping after specified number of milliseconds- Parameters:
lambda- code blockmillis- time constrained in millisecondsfailExpr- returns this if the time constraint is not met
-
timeConstrained
public static <T> T timeConstrained(Callable<T> lambda, long millis) throws InterruptedException, ExecutionException
Runs lambda, stopping after specified number of milliseconds- Parameters:
lambda- code blockmillis- time constrained in milliseconds- Throws:
InterruptedExceptionExecutionException
-
-