Viua should support programs spanning multiple threads.
To avoid problems with locking, machine-local threads will share no state (i.e. take the Erlang approach of a process-like threads). Sample code:
; create a frame
frame ^[(param 0 (istore 1 42))]
; spawn a thread starting with function foo
thread 2 foo
; join a thread from handle stored in register 2, and store the value it returned in register 3
; this will cause the execution to wait for the thread to finish if needed
tjoin 3 2
Threads can be spawned only from functions (i.e. the callable that the thread is started from must be a function).
First, the code should be refactored so that the main execution thread is also a thread. Given current state of things, machine is hopelessly singlethreaded.
Viua should support programs spanning multiple threads.
To avoid problems with locking, machine-local threads will share no state (i.e. take the Erlang approach of a process-like threads). Sample code:
Threads can be spawned only from functions (i.e. the callable that the thread is started from must be a function).