pub struct Config {
pub grace: Duration,
pub preempt_every: Option<u32>,
}Expand description
Settings of a VM. One per VM, read and written through Vm
(Vm::attach, Vm::config, Vm::set_config).
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).
Trait Implementations§
impl Copy for Config
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more