Closed marekjm closed 8 years ago
This issue is ridden with either race conditions, or deadlock "opportunities" if not implemented correctly. After I spent some time thinking about it, maybe even the current, simple model has problems.
The idea of multiple joins is abandoned for now. Only parent can join its child process.
I'm closing the issue for now. It may be reopened later, after I have come up with a better design for it. The version I started implementing looked too convoluted I decided to nuke it.
Currently,
join
instruction receives a process handle and blocks invoking process's execution until the process-to-be-joined finishes running (either successfully, or by crashing). Also, processes may be either detached or joinable, and only joinable processes can be joined.This issue proposes to abolish the detached-joinable distinction and run all processes as detached.
Then,
join
would be made a subscribe operation; a process A joining another process B would be just telling Viua that it is interested in the final result of the process B, and the VM will deliver this result and unblock the process A once B finished running. Delivered result may be either an object that the main function of process B produced, or an exception if the process B crashed.This model has a certain advantage over the current one - multiple processes would be able to join a single process, an action which is impossible under current model.