Skip to main content

Coro

Struct Coro 

Source
pub struct Coro {
Show 15 fields pub status: CoroStatus, pub body: Value, pub started: bool, pub resumer: Option<Gc<Coro>>, pub resume_at: Option<(u32, i32)>, pub error_value: Option<Value>, pub error_traceback: Option<Vec<u8>>, pub stack: Vec<Value>, pub frames: Vec<CallFrame>, pub open_upvals: Vec<(u32, Gc<Upvalue>)>, pub tbc: Vec<u32>, pub top: u32, pub pcall_depth: u32, pub hook: HookState, pub globals: Gc<Table>, /* private fields */
}
Expand description

A Lua coroutine (thread) — one independent execution context plus its saved value/frame stacks and resume linkage.

Fields§

§status: CoroStatus

Resume state (suspended / running / normal / dead).

§body: Value

the body function, kept for the first resume (and as a GC root)

§started: bool

whether the body frame has been pushed yet (first resume vs. continue)

§resumer: Option<Gc<Coro>>

the coroutine that resumed this one (to restore on yield/return and for coroutine.running); None once suspended/dead

§resume_at: Option<(u32, i32)>

where execution suspended on yield: the call slot and result count to finish that call with the next resume’s arguments

§error_value: Option<Value>

the error object a coroutine died with (when it errored rather than returned); coroutine.close reports it once, then clears it

§error_traceback: Option<Vec<u8>>

snapshot of the traceback at the error point — captured before the dying coroutine’s frames are unwound, so debug.traceback(co) on a dead-with-error coroutine still shows the error site (PUC’s luaG_errormsg flow plus a per-thread errfunc snapshot).

§stack: Vec<Value>

Saved value stack.

§frames: Vec<CallFrame>

Saved frame stack (Lua frames + native continuations).

§open_upvals: Vec<(u32, Gc<Upvalue>)>

Open-upvalue list — (stack slot, upvalue cell) pairs.

§tbc: Vec<u32>

Stack indices of registered <close> slots (5.4+).

§top: u32

Saved stack top.

§pcall_depth: u32

live pcall/xpcall continuation count (PUC nCcalls portion); see Vm

§hook: HookState

this thread’s debug hook state (PUC per-thread hook/hookmask)

§globals: Gc<Table>

PUC L->l_gt — the thread’s own globals table. Captured from the resuming thread at create time, then swapped with Vm.globals on every resume/yield boundary so a setfenv(0, env) inside the coroutine only retunes this thread (5.1 closure.lua :177 pins this — yielding getfenv() after the rewire must see the coroutine’s own per-closure env, not the caller’s).

Auto Trait Implementations§

§

impl !RefUnwindSafe for Coro

§

impl !Send for Coro

§

impl !Sync for Coro

§

impl !UnwindSafe for Coro

§

impl Freeze for Coro

§

impl Unpin for Coro

§

impl UnsafeUnpin for Coro

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.