Module yarn

multi threading library

Introduction#

Yarn is a simple multithreading library (lol). Threads are individual Lua states, so they do NOT share the same environment (variables) as the code that runs the thread. Bait and Commanders are shared though, so you can throw hooks from 1 thread to another. You may use that as a way to pass variables and data to a Yarn thread.

Example:

local yarn = require 'yarn'

-- calling t will run the yarn thread.
local t = yarn.thread(print)
t 'printing from another lua state!'

Functions#


thread#

yarn.thread(fun) -> Thread

Since: 3.0.0

Creates a new, fresh Yarn thread.

Parameters#

function fun The function that will run in the thread.

Returns#

Thread The created yarn thread.

Types#


Thread#

A thread is a Lua state that can be executed independently. You call a thread object as a function to run the thread with the provided arguments.

Methods#