I don’t have any links since I’ve only seen minor references to it across the forums, but think about this:
race:
block:
Print("First")
Sleep(Time)
block:
Print("Second")
Sleep(Time)
block:
Print("Third")
Sleep(Time)
The expressions in the race
block run sequentially, and the next expression is only ran once the previous expression has been suspended (by Sleep
in these examples) - it’s exactly the same with sync
, which runs its expressions “at the same time” but only running each expression after the previous one has completed, top-to-bottom.
spawn
is the same concept - it’s not creating a new thread and running the spawned function at the same time as the code following the spawn
, but rather running it on the main thread up until it hits its first suspending expression, then allowing the scope that called the spawn
to continue (like calling an async JavaScript function without await
).
If Verse wasn’t single threaded, using expressions like race
or spawn
would produce very different results because of race conditions, especially when coupled with mutation.