pub struct InterruptHandle { /* private fields */ }Expand description
Thread-safe request to abort JavaScript execution on one runtime.
Obtain it from JSRuntime::interrupt_handle() or Worker::interrupt_handle().
A persistent request made with interrupt remains active
until clear. For independently owned requests, prefer
interrupt_scoped, which cannot be cleared by
another scoped caller.
The handle remains safe to use after the runtime is gone; its local request state still changes, but there is no longer a runtime to affect.
Implementations§
Source§impl InterruptHandle
impl InterruptHandle
pub fn new() -> Self
Sourcepub fn interrupt(&self)
pub fn interrupt(&self)
Request interruption until clear is called.
Running JavaScript is aborted on preemptive engines and new evaluations are rejected on every engine. Repeated calls are idempotent.
Sourcepub fn clear(&self)
pub fn clear(&self)
Clear this handle’s persistent interruption request.
Scoped requests remain active until their InterruptGuard is dropped.
Clearing does not resume an aborted script; it only permits subsequent
JavaScript execution.
Sourcepub fn interrupt_scoped(&self) -> InterruptGuard
pub fn interrupt_scoped(&self) -> InterruptGuard
Request interruption for the lifetime of the returned guard.
Scoped requests compose safely: dropping one guard does not clear a persistent request or another live guard’s request.
Sourcepub fn is_interrupted(&self) -> bool
pub fn is_interrupted(&self) -> bool
Whether any persistent or scoped interruption request is active.
Sourcepub fn mode(&self) -> InterruptMode
pub fn mode(&self) -> InterruptMode
The interruption behavior of the bound engine.
Trait Implementations§
Source§impl Clone for InterruptHandle
impl Clone for InterruptHandle
Source§fn clone(&self) -> InterruptHandle
fn clone(&self) -> InterruptHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more