pub struct CancelToken { /* private fields */ }Expand description
Cancellation signal shared between caller and Lua thread.
Clone is cheap (Arc).
Two cancellation pathways are wired:
-
A Lua debug hook polls
is_cancelledeveryNLua instructions. This interrupts pure-Lua CPU-bound loops (while true do endetc). -
When the feature
tokiois enabled,cancelledprovides an async signal that fires as soon ascancelis called. Coroutine executors (execute_coroutine_eval,execute_coroutine_call) use this in atokio::select!to drop the in-flight Lua coroutine even when the coroutine is suspended inside a Rust.await(e.g. acreate_async_functionawaiting a tokio child process). The debug hook alone cannot interrupt such Rust-suspended coroutines because no Lua instructions execute during the.await, so the hook never fires.
Implementations§
Source§impl CancelToken
impl CancelToken
Trait Implementations§
Source§impl Clone for CancelToken
impl Clone for CancelToken
Source§fn clone(&self) -> CancelToken
fn clone(&self) -> CancelToken
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CancelToken
impl RefUnwindSafe for CancelToken
impl Send for CancelToken
impl Sync for CancelToken
impl Unpin for CancelToken
impl UnsafeUnpin for CancelToken
impl UnwindSafe for CancelToken
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