spawn
Description
Spawns a new fiber to run f. Post semantics are used, so the current fiber
(the one calling spawn()) continues to run until it reaches a suspension
point.
Fibers are the primitive of choice to represent concurrency. Every time you need
to increase the concurrency level, just spawn a fiber. Fibers are
cooperative 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.
No two fibers from the same Lua VM run in parallel (even when the underlying VM’s thread pool has threads available).
| spawn()is a global so it doesn’t need to berequire()d. |