2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-01 08:42:04 +00:00
Hilbish/docs/api/yarn.md
2025-06-18 20:37:43 -04:00

1.5 KiB

title description layout menu
Module yarn multi threading library doc
docs
parent
API

Introduction

Yarn is a simple multithreading library. Threads are individual Lua states, so they do NOT share the same environment as the code that runs the thread. Bait and Commanders are shared though, so you can throw hooks from 1 thread to another.

Example:

local yarn = require 'yarn'

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

Functions

<div class='relative overflow-x-auto sm:rounded-lg my-4'>
<table class='w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400'>
<tbody>
<tr class='bg-white border-b dark:bg-neutral-800 dark:border-neutral-700 border-neutral-200'>
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'><a href="#thread">thread(fun) -> @Thread</a></td>
<td class='p-3 font-medium text-black whitespace-nowrap dark:text-white'>Creates a new, fresh Yarn thread.</td>
</tr>
</tbody>
</table>
</div>

Functions

<hr class='my-4 text-neutral-400 dark:text-neutral-600'>
<div id='thread'>
<h4 class='text-xl font-medium mb-2'>
yarn.thread(fun) -> @Thread
<a href="#thread" class='heading-link'>
	<i class="fas fa-paperclip"></i>
</a>
</h4>

Creates a new, fresh Yarn thread.
fun is the function that will run in the thread.

Parameters

This function has no parameters.

Types

<hr class='my-4 text-neutral-400 dark:text-neutral-600'>

Thread

Methods