EMILUA(3em)
β¨ NAME β¨
Emilua - Lua execution engine β yes bestie, thatβs the whole name, and itβs iconic π
okay so welcome to EMILUA(3em), the page where we talk about spawning fibers and keeping your concurrency cute and controlled π
π«Ά SYNOPSIS π«Ά
spawn(f: function) -> fiber
π DESCRIPTION π
So spawn() spawns a new fiber to run f, no cap. It uses post semantics, so the current fiber β the one calling spawn() β keeps running until it reaches a suspension point. Thatβs the vibe.
Fibers are the primitive of choice to represent concurrency. Every time you need to increase the concurrency level, just spawn a fiber. Simple as that, periodt β¨
Fibers are cooperative (https://en.wikipedia.org/wiki/Cooperative_multitasking) and only transfer control to other fibers in well-defined points β sync primitives, IO functions, and any suspending function such as this_fiber.yield(). These points are also used by the cancellation API. iykyk π¦
No two fibers from the same Lua VM run in parallel β even when the underlying VMβs thread pool has threads available. fr fr, thatβs important π
Note:spawn()is a global so it doesnβt need to berequire()d. main character energy, honestly π
π§ fiber FUNCTIONS π§
πΈ join(self) πΈ
Read pthread_join().
Returns the values returned by the fiberβs start function. If that fiber exits with an error, that error is re-raised here (and fiber is considered joined). so real π
π¦ detach(self) π¦
Read pthread_detach().
If the GC collects the fiber handle, itβll be detached.
π cancel(self) π
Read pthread_cancel().
π fiber PROPERTIES π
β cancellation_caught: boolean β
Read PTHREAD_CANCELED.
π joinable: boolean π
Whether joinable.
okay bye bestie β this β¨iconicβ¨ page is serving Emilua 0.12.1-nixpkgs1, dated 1980-01-01 β periodt π
π
π¦ where this page comes from
- nixos 26.05: emilua 0.12.1
- nixpkgs unstable: emilua 0.12.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms