[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to get the current thread in C code?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 21 Dec 2006 07:25:49 -0200
> But message process and create window may not in the same coroutine.
> For example, if you are calling UpdateWindow in a lua coroutine.
> UpdateWindow will call SendMessage(hWnd,WM_PAINT) , and this will call
> my WinProc . At this time, it needs coroutine's lua_State *L , not the
> lua_State at the time window created .
This is a common problem in some APIs. If you cannot store callback data
in WinProc, then the best you can do is to store the Lua state in a global
variable everytime you get in C from Lua, ie, everytime Lua calls C. I've
done that on a some occasions for error handling and other interrupts.
See my lalarm, lbc, lgdbm and lmapm. Look for LL.
--lhf