Record Class TimeLimitControl
- Record Components:
timeLimit
- the maximum execution time allowed
- All Implemented Interfaces:
Control
Control
that limits the amount of time that a script snippet may execute.
This class works by adding time checks to method entry points and backward branches. Therefore, it only works when the executing thread is actually executing (i.e., not blocked).
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.dellroad.javabox.Control
Control.ContainerContext, Control.ExecutionContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
check()
final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.byte[]
modifyBytecode
(ClassDesc name, byte[] bytes) Adds time limit checks to the bytecode.startExecution
(Control.ContainerContext context) Notification that the execution of a script snippet has started.Returns the value of thetimeLimit
record component.final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.dellroad.javabox.Control
finishExecution, initialize, shutdown
-
Constructor Details
-
TimeLimitControl
Constructor.- Throws:
IllegalArgumentException
- iftimeLimit
is more than 263 nanosecondsIllegalArgumentException
- iftimeLimit
is null or negative
-
-
Method Details
-
modifyBytecode
Adds time limit checks to the bytecode.- Specified by:
modifyBytecode
in interfaceControl
- Parameters:
name
- the name of the class being addedbytes
- the Java bytecode of the class being added- Returns:
- replacement java bytecode; must not be null
-
startExecution
Description copied from interface:Control
Notification that the execution of a script snippet has started.This method should initialize this control for the new execution and return any associated private context.
This method should also perform any required per-execution initialization, for example, initializing resource counters, etc.
The current thread will be the thread that is actually executing the script snippet. A
Control.ExecutionContext
will be created using the returned private context and made available in this thread viaJavaBox.executionContextFor()
, and also provided tofinishExecution()
.The default implementation in
Control
returns null.- Specified by:
startExecution
in interfaceControl
- Parameters:
context
- the container context for this control
-
check
public static void check() -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
timeLimit
-