Skip to content

How should you set up threading for Luau? #311

Answered by zeux
moonshineTheleocat asked this question in Q&A
Discussion options

You must be logged in to vote

Luau currently requires the host to ensure exclusive access to different VMs (aka top-level lua_State), which is the same requirement that Lua has. Separate coroutines that belong to the same state can not be executed or worked with concurrently, as internal components of the VM such as the garbage collector are not thread-safe. The term thread in lua_newthread refers to the thread of execution within the VM (better known as coroutine), and should not be confused with hardware threads.

In Roblox, we create many VMs and load individual scripts into separate VMs; since we expose some host objects to all VMs via bindings, we can provide a way for threads to communicate by unmarshalling the L…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zeux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants