pub(crate) struct RUnwind {
token: SEXP,
boundary: u64,
}Expand description
An R non-local exit that call_unwinding carries out of its callback
as a Rust unwind: an error, a condition caught by an exiting handler set up
outside the call (tryCatch(warning = )), a restart, an interrupt.
The unwind runs the destructors of the Rust frames between the evaluation
and the boundary that catches it. The boundary (run_r_unwind_protect,
the FFI guards) then resumes the exit with
R_ContinueUnwind, and R carries on to the context it was jumping to, with
the condition object and call it was jumping with.
The continuation token is private to one evaluation and preserved until the exit resumes, so R code that a destructor runs during the unwind (a protected call of its own, which reuses the shared token) cannot overwrite the pending jump or let the collector reclaim it (#1507).
Fields§
§token: SEXPR_MakeUnwindCont(), preserved: the jump target and the value R was
jumping with.
boundary: u64The Boundary that was innermost when the evaluation started.
Implementations§
Source§impl RUnwind
impl RUnwind
Sourcepub(crate) fn belongs_to(&self, boundary: &Boundary) -> bool
pub(crate) fn belongs_to(&self, boundary: &Boundary) -> bool
Whether boundary may resume this exit: the boundary its evaluation
ran in, still on the stack.
Sourcepub(crate) unsafe fn resume(self) -> !
pub(crate) unsafe fn resume(self) -> !
Continue the R exit where R_UnwindProtect stopped it. Never returns.
§Safety
R’s main thread, at the boundary the exit belongs_to,
after its Boundary::leave, with no Rust value left to drop between
this call and the R context that owns the frame (the C entry point R
called).
Trait Implementations§
Source§impl Drop for RUnwind
impl Drop for RUnwind
Source§fn drop(&mut self)
fn drop(&mut self)
Reached when something other than the exit’s boundary caught the unwind
and dropped it, or the boundary refused it (RUnwind::stray). The R
exit is abandoned: R carries on from where the evaluation stopped, as
after R_tryEval. Release the token, on R’s main thread: dropped on
another thread (code that moved the caught payload there), it goes to
the main thread over ABANDONED_SENDER and the next evaluation
releases it.
Off the main thread the token is sent with try_send, never send: the
main thread may be joining the dropping thread, and a blocking send
would wait for it forever. When the channel is full (more than
ABANDONED_CAPACITY exits dropped off the main thread between two
evaluations) or not open yet, the token stays preserved, and R keeps
the value the exit carried: a leak, not a crash.
Auto Trait Implementations§
impl Forget for RUnwind
impl Freeze for RUnwind
impl RefUnwindSafe for RUnwind
impl Send for RUnwind
impl Sync for RUnwind
impl Unpin for RUnwind
impl UnsafeUnpin for RUnwind
impl UnwindSafe for RUnwind
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> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize
#[doc(hidden)]const SIZE: usize
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize
#[doc(hidden)]const ALIGN: usize
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment
#[doc(hidden)]const ALIGNMENT: Alignment
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool
#[doc(hidden)]const IS_ZST: bool
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout
#[doc(hidden)]const LAYOUT: Layout
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize
#[doc(hidden)]const MAX_SLICE_LEN: usize
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes