Object referring to current fiber.

this_fiber is a global so it doesn’t need to be require()d.



Reschedule current fiber to be executed in the next round so other ready fibers have a chance to run now. You usually don’t need to call this function as any suspending function already do that.



A call to forbid_suspend() will put the fiber in the state of suspension-disallowed and any attempt to suspend the fiber while it is in this state will raise an error.

forbid_suspend() may be called multiple times. A matching number of calls to allow_suspend() will put the fiber out of the suspension-disallowed state. You must not call allow_suspend() if there was no prior call to forbid_suspend().

These functions aren’t generally useful and they would have no purpose in preemptive multitasking. However a cooperative multitasking environment offers opportunities to avoid some round-trips to sync primitives. These opportunities shouldn’t really be used and the programmer should just rely on the classical sync primitives. However I can’t tame every wild programmer out there so there is this mechanism to at least document the code in mechanisms similar to assert() statements from native languages.

They’re only useful if there are comprehensive test cases. Still, the use of these functions may make the code more readable. And some tools may be developed to understand these blocks and do some simple static analysis.



Check the interruption tutorial to see what it does.


is_main: boolean

Whether this is the main fiber of the program.

local_: table

Fiber-local storage.

id: string

An id string for debugging purposes.

Use it only for debugging purposes. Do not exploit this value to create messy work-arounds. There is no need to use it beyond anything other than debugging purposes.