pub struct CancelConfig {
pub grace: Duration,
pub preempt_every: Option<u32>,
}Expand description
Cancellation settings of a VM. Set with configure.
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).
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 isle 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§
Source§impl Clone for CancelConfig
impl Clone for CancelConfig
impl Copy for CancelConfig
Source§impl Debug for CancelConfig
impl Debug for CancelConfig
Source§impl Default for CancelConfig
impl Default for CancelConfig
impl Eq for CancelConfig
Source§impl PartialEq for CancelConfig
impl PartialEq for CancelConfig
impl StructuralPartialEq for CancelConfig
Auto Trait Implementations§
impl Freeze for CancelConfig
impl RefUnwindSafe for CancelConfig
impl Send for CancelConfig
impl Sync for CancelConfig
impl Unpin for CancelConfig
impl UnsafeUnpin for CancelConfig
impl UnwindSafe for CancelConfig
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