marekjm / viuavm

Parallel virtual machine designed to reliably run massively concurrent programs
https://viuavm.org/
GNU General Public License v3.0
71 stars 11 forks source link

Add a way to extract work result from a thread #104

Closed marekjm closed 8 years ago

marekjm commented 8 years ago

As in the title. Machine should provide a way of extracting return values from finished threads.

If an exception has been thrown but has not been handled in the child thread, extracting return value would rethrow it inside parent thread. To prevent the exception from being rethrown user can send the terminated/1 message to a thread to check if it has been terminated.

marekjm commented 8 years ago

This will require amending thjoin instruction. It should take two operands instead of one:

  1. the index of return register (the return value of a thread is return value of a top-most function),
  2. index of register containing handle of the thread to join,

Code:

; old syntax
thjoin <thread-handle>

; new syntax
thjoin <return-register> <thread-handle>