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: CoroStatusResume state (suspended / running / normal / dead).
body: Valuethe body function, kept for the first resume (and as a GC root)
started: boolwhether 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: u32Saved stack top.
pcall_depth: u32live pcall/xpcall continuation count (PUC nCcalls portion); see Vm
hook: HookStatethis 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).