[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to get the current thread in C code?
- From: Cloud Wu <cloudwu@...>
- Date: Wed, 20 Dec 2006 23:11:18 +0800
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.
[一人之断制, 所见有限, 犹目之一瞥, 岂能尽万物之情乎]