lua-users home
lua-l archive

Re[2]: How to get the current thread in C code?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello Linker,
Wednesday, December 20, 2006, 10:35:30 PM, you wrote:
LL> You can store the handle of the thread in the _G[ ] table in Lua when you created a thread.
LL> The handle is a ID number (or a string) of the thread.
LL> Then in C, you can call the func getThread(lua_number ID) to pass the ID to Lua and
LL> get the lua_State of the thread.
I mean lua coroutine, not os thread :)
WinProc in my application is always called by a lua function
indirectly, but I don't know which lua coroutine call it.
I can't get the suitable lua_State pointer in the WinProc , because
different lua coroutine has different lua_State pointer.
The correct lua_State pointer must exist in C's stack, but I have no way to
let WinProc get it.
So all I need is detect which lua coroutine is running, and that one
must be the lua_State I need.
-- 
Best regards,
 Cloud mailto:cloudwu@163.com
 http://blog.codingnow.com
[一人之断制, 所见有限, 犹目之一瞥, 岂能尽万物之情乎]

AltStyle によって変換されたページ (->オリジナル) /