pub type CancelConfig = Config;use mlua_isle::runtime::Config
Expand description
Settings of a VM. Now runtime::Config, the same struct (this is
an alias of it).
Aliased Type§
pub struct CancelConfig {
pub grace: Duration,
pub preempt_every: Option<u32>,
}Fields§
§grace: DurationHow long a cancelled coroutine request or task may keep running to finish its cleanup before it is dropped.
On cancel, the coroutine first receives the cancellation as a Lua
error (from the cancel hook while it runs, or from an async
function wrapped with cancellable while it awaits). That error
unwinds normally, so __close handlers run and may await. If
the coroutine has not finished when the grace period ends, it is
dropped: the awaited Rust future is released, and pending
__close handlers run without being able to yield (a Lua 5.4
restriction).
The grace period is one deadline for the cancelled request or
task and every task it spawned, transitively: a task started
during cleanup (from a __close handler, say) gets the time that
remains, not a fresh grace period.
Default: zero (drop at once).
preempt_every: Option<u32>Yield the running coroutine request or task every this many cancel checks (a check runs every 1000 instructions), so that other tasks on the same thread, including one that cancels it, get to run while it is in a CPU loop.
Only the coroutine that the crate created for the request or task
is yielded, never a coroutine the Lua code created itself (that
yield would reach the Lua code’s own coroutine.resume as a
spurious yield). Code in a non-yieldable context (a metamethod,
a C function boundary) is not yielded.
Yielding lets other tasks interleave at points the Lua code did not mark, so Lua code that updates shared state across such a point can observe changes made by another task.
Default: None (never preempt).