Skip to main content

Module coro_lib

Module coro_lib 

Source
Expand description

Coroutine library — port of lcorolib.c.

Provides the coroutine.* standard-library table: create, resume, running, status, wrap, yield, isyieldable, and close.

§Phase A–D stub notice

Every function that requires actual coroutine execution (resume, yield, cross-thread xmove, new_thread, close_thread) is unimplemented and will panic at runtime. The argument-checking and result-packaging logic is translated faithfully so that Phase E can drop in the real implementations without restructuring. Phase E wires real stackful coroutines via corosensei. See PORTING.md §2 #6.

Translated from: reference/lua-5.4.7/src/lcorolib.c (210 lines, 12 functions) Target crate: lua-stdlib

Constants§

CO_FUNCS
Registration table for the coroutine standard library.

Functions§

co_close
coroutine.close(co) — close a dead or suspended coroutine.
co_create
coroutine.create(f) — create a new coroutine that will run function f.
co_isyieldable
coroutine.isyieldable([co]) — test whether a coroutine (default: current) is in a yieldable state.
co_resume
coroutine.resume(co [, val1, ...]) — attempt to resume coroutine co.
co_running
coroutine.running() — return the current coroutine plus a boolean.
co_status
coroutine.status(co) — return a string describing co’s current status.
co_wrap
coroutine.wrap(f) — create a coroutine and return a resuming function.
co_yield
coroutine.yield([...]) — suspend the running coroutine.
open_coroutine
Opens the coroutine standard library by pushing a new table containing all coroutine.* functions.