I am trying to come up with a solution for yielding a Luajit coroutine from a C function that immediately creates a tasklet to be processed on another OS thread.
According to various Lua documentations, and things began to heavily contradict each other, this isn't entirely possible? The documentations are not very clear, and they don't explain the reasoning.
Lua 5.1 states that each each coroutine had a stack. However, there was only one global C stack. I am not entirely sure why that is a hindrance.
Lua 5.2 apparently fixes this with lua_pcallk and lua_yieldk. But the explanations are very confusing.
But none of these states the VM that I am using... which is LuaJIT 2.0.4 and LuaJIT 2.1.0.
A google search told me that Luajit 1.x had CoCo implemented, which apparently used true C stacks for each lua thread (coroutine). Which allows yielding from anywhere.
And only one search lead me to see that apparently LuaJIT 2.x does not implement coco, as each coroutine uses a C stack.
Could anyone please tell me what the problem is for yielding a coroutine from C? And verify whether or not I can safely yield/resume a luajit 2.x coroutine from c?