Is there a way to know which thread (coroutine) executing a Lua script is at the origin of a lua_pushcclosure call?
In order to manage some stuff relative to lua threads (delayed pause/resume, or private thread variables) I need to identify the thread involved in the callback. I know I can get the thread index when creating it by using lua_gettop, but I can't find a way to use it so it helps identifying the thread when a lua_pushcclosure call is issued from a Lua script.
My current system permits nested script calls, so a script can execute other scripts (each nested script call create a new thread with the same lua_state. Thus the lua_state used to get multiple thread entries in the stack.)
I'm using Lua 5.2