WardrikLua. Sandbox. Runner
(wardrik_lua v0.1.0-rc.1)
Copy Markdown
Runs one evaluation in a task of its own, bounded by WardrikLua.Sandbox.Limits.
WardrikLua.Sandbox.Runner.run(fn -> {:ok, 4} end, WardrikLua.Sandbox.Limits.new())
#=> {:ok, 4}WardrikLua.Sandbox.run/2 calls it. The VM implements the language; this module bounds the
process.
The task runs at low priority under its own task supervisor. It's killed when it passes its deadline, outgrows its memory budget, or its caller dies.
Notes
- The task isn't linked to its caller. The BEAM kills a process that outgrows its heap, and a link would pass that kill on to the waiting tool call. The caller monitors the task instead. The task supervisor is linked to the caller, so it takes the task down if the caller dies.
- The heap cap is the BEAM's
:max_heap_size. Off-heap binaries aren't counted by it, so they are polled every 50ms. Either budget can be overshot by one interval's work.
Summary
Functions
Runs fun under limits. Returns its result, or an error naming the limit that stopped it.
Types
Functions
@spec run((-> result()), WardrikLua.Sandbox.Limits.t()) :: result()
Runs fun under limits. Returns its result, or an error naming the limit that stopped it.