getinterp P2 find_method P0, P2, "thread" find_global P6, "_foo" clone P5, P2 invoke # start the thread
This little piece of code runs the subroutine "_foo" in a separate thread inside interpreter P5.
There are of course a lot of things missing, ParrotInterpreter::clone does only very basic things and so on, but it runs.
Some remarks and thoughts:
1) We have to store the Parrot_thread somewhere - I'm thinking of:
struct thread_data inside the interpreter structure
2) All interpreters get stored in a global Interp_Array, the index being the user visible thread id for e.g. join.
3) Shared PMCs should probably get their own pmc-pool memory.
4) above code snippet could be one single op:
thread (out INT, in PMC) # run sub $2 threaded, ret thread id in $1
Further pointers and comments are very welcome.
Have fun, leo