LuaExecutionBudget
Enforces a hard execution budget inside the Lua VM.
Measuring elapsed time after a Lua callback returns cannot protect the server from a script that never returns. LuaJ calls onInstruction while executing bytecode, which gives us a cooperative interruption point without running Bukkit-facing scripts on an unsafe worker thread.
The time budget uses current-thread CPU time so a valid script is not charged for time when its server thread is descheduled. JVMs without that clock use a deliberately more generous elapsed fallback; the instruction ceiling remains active in either mode, so the fallback does not make non-terminating scripts unbounded.
Types
Functions
Link copied to clipboard
public static LuaExecutionBudget.Measurement<T> measure<T>(Supplier<T> call, long maxCpuNanos, long maxInstructions)
Runs source initialization and its hook under one existing VM watchdog.