sgs_CreateSubthread [function]
void sgs_CreateSubthread( sgs_Context* T, sgs_Context* C, sgs_Variable* out, sgs_StkIdx args, int gotthis )
Creates a thread (managed coroutine) with a starting function.
T is the parent thread (use sgs_RootContext for a global thread and same as C for a local thread).
C contains the function and arguments.
- If
out is NULL, new thread is pushed to C's stack, otherwise it is assigned to that variable.
args and gotthis specify how to interpret the values pushed on stack (function expects args + (gotthis?1:0) + 1 values).
- Thread is started before returning from this function.