EMILUA(3em)

πŸ“¦ version 0.12.1, in nixos 26.05, nixpkgs unstable

✨ 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 be require()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